X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Fabstract-worker.ts;h=ec77ccab8d68c7990339b9331cf6fd4903a7d1fe;hb=f22545899538e05c24ec929bbc16444b7bc23cb0;hp=9b9ded5e9d1cc1267846fb9e0279d88de405262f;hpb=3a5027122ca6401ae1d755843b20f714c61e3240;p=poolifier.git diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 9b9ded5e..ec77ccab 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -355,9 +355,10 @@ export abstract class AbstractWorker< switch (taskFunctionOperation) { case 'add': response = this.addTaskFunction(taskFunctionProperties.name, { - // eslint-disable-next-line no-new-func + // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func taskFunction: new Function( - `return ${taskFunction}` + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + `return ${taskFunction!}` )() as TaskFunction, ...(taskFunctionProperties.priority != null && { priority: taskFunctionProperties.priority, @@ -398,7 +399,7 @@ export abstract class AbstractWorker< protected handleKillMessage (message: MessageValue): void { this.stopCheckActive() if (isAsyncFunction(this.opts.killHandler)) { - ;(this.opts.killHandler() as Promise) + ;(this.opts.killHandler as () => Promise)() .then(() => { this.sendToMainWorker({ kill: 'success' }) return undefined @@ -408,7 +409,7 @@ export abstract class AbstractWorker< }) } else { try { - this.opts.killHandler?.() + ;(this.opts.killHandler as (() => void) | undefined)?.() this.sendToMainWorker({ kill: 'success' }) } catch { this.sendToMainWorker({ kill: 'failure' }) @@ -426,7 +427,7 @@ export abstract class AbstractWorker< throw new Error('Message worker id is not set') } else if (message.workerId !== this.id) { throw new Error( - `Message worker id ${message.workerId} does not match the worker id ${this.id}` + `Message worker id ${message.workerId.toString()} does not match the worker id ${this.id.toString()}` ) } } @@ -514,7 +515,8 @@ export abstract class AbstractWorker< workerError: { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion name: name!, - message: `Task function '${name}' not found`, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + message: `Task function '${name!}' not found`, data, }, taskId,