X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fabstract-pool.ts;h=3b676faa7a4f28309743d38328ab0e35ab80818a;hb=1514944d2861b75bf40f0543b72728c6030a67f6;hp=e4dac676ab95acae7ee60a82d332084766735e46;hpb=ec8ed549f5422b9c23ff5b446ec885f39656373d;p=poolifier.git diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index e4dac676..3b676faa 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -658,7 +658,7 @@ export abstract class AbstractPool< throw new Error('Worker message received without worker id') } else if (this.getWorkerNodeKeyByWorkerId(message.workerId) === -1) { throw new Error( - `Worker message received from unknown worker '${message.workerId}'` + `Worker message received from unknown worker '${message.workerId.toString()}'` ) } } @@ -891,7 +891,11 @@ export abstract class AbstractPool< } else { reject( new Error( - `Task function operation '${message.taskFunctionOperation}' failed on worker ${message.workerId} with error: '${message.workerError?.message}'` + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `Task function operation '${message.taskFunctionOperation?.toString()}' failed on worker ${message.workerId?.toString()} with error: '${ + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + message.workerError?.message + }'` ) ) } @@ -939,7 +943,9 @@ export abstract class AbstractPool< new Error( `Task function operation '${ message.taskFunctionOperation as string - }' failed on worker ${errorResponse?.workerId} with error: '${ + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + }' failed on worker ${errorResponse?.workerId?.toString()} with error: '${ + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions errorResponse?.workerError?.message }'` ) @@ -1284,6 +1290,7 @@ export abstract class AbstractPool< private async sendKillMessageToWorker (workerNodeKey: number): Promise { await new Promise((resolve, reject) => { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (this.workerNodes[workerNodeKey] == null) { resolve() return @@ -1295,7 +1302,8 @@ export abstract class AbstractPool< } else if (message.kill === 'failure') { reject( new Error( - `Kill message handling failed on worker ${message.workerId}` + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `Kill message handling failed on worker ${message.workerId?.toString()}` ) ) } @@ -1351,6 +1359,7 @@ export abstract class AbstractPool< workerNodeKey: number, task: Task ): void { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (this.workerNodes[workerNodeKey]?.usage != null) { const workerUsage = this.workerNodes[workerNodeKey].usage ++workerUsage.tasks.executing @@ -1391,6 +1400,7 @@ export abstract class AbstractPool< message: MessageValue ): void { let needWorkerChoiceStrategiesUpdate = false + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (this.workerNodes[workerNodeKey]?.usage != null) { const workerUsage = this.workerNodes[workerNodeKey].usage updateTaskStatisticsWorkerUsage(workerUsage, message) @@ -1568,6 +1578,7 @@ export abstract class AbstractPool< ) { this.redistributeQueuedTasks(this.workerNodes.indexOf(workerNode)) } + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition workerNode?.terminate().catch((error: unknown) => { this.emitter?.emit(PoolEvents.error, error) }) @@ -1786,6 +1797,7 @@ export abstract class AbstractPool< taskName: string ): void { const workerNode = this.workerNodes[workerNodeKey] + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (workerNode?.usage != null) { ++workerNode.usage.tasks.stolen } @@ -1804,6 +1816,7 @@ export abstract class AbstractPool< previousTaskName?: string ): void { const workerNode = this.workerNodes[workerNodeKey] + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (workerNode?.usage != null) { ++workerNode.usage.tasks.sequentiallyStolen } @@ -1832,6 +1845,7 @@ export abstract class AbstractPool< taskName: string ): void { const workerNode = this.workerNodes[workerNodeKey] + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (workerNode?.usage != null) { workerNode.usage.tasks.sequentiallyStolen = 0 } @@ -1859,7 +1873,7 @@ export abstract class AbstractPool< const workerInfo = this.getWorkerInfo(workerNodeKey) if (workerInfo == null) { throw new Error( - `Worker node with key '${workerNodeKey}' not found in pool` + `Worker node with key '${workerNodeKey.toString()}' not found in pool` ) } if ( @@ -1975,7 +1989,7 @@ export abstract class AbstractPool< const workerInfo = this.getWorkerInfo(workerNodeKey) if (workerInfo == null) { throw new Error( - `Worker node with key '${workerNodeKey}' not found in pool` + `Worker node with key '${workerNodeKey.toString()}' not found in pool` ) } workerInfo.stealing = true @@ -2032,7 +2046,8 @@ export abstract class AbstractPool< private handleWorkerReadyResponse (message: MessageValue): void { const { workerId, ready, taskFunctionsProperties } = message if (ready == null || !ready) { - throw new Error(`Worker ${workerId} failed to initialize`) + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + throw new Error(`Worker ${workerId?.toString()} failed to initialize`) } const workerNodeKey = this.getWorkerNodeKeyByWorkerId(workerId) const workerNode = this.workerNodes[workerNodeKey] @@ -2068,10 +2083,12 @@ export abstract class AbstractPool< this.afterTaskExecutionHook(workerNodeKey, message) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.promiseResponseMap.delete(taskId!) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition workerNode?.emit('taskFinished', taskId) if ( this.opts.enableTasksQueue === true && !this.destroying && + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition workerNode != null ) { const workerNodeTasksUsage = workerNode.usage.tasks