X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=inline;f=src%2Fworker%2Fabstract-worker.ts;h=ebbefc75ba4cc8c4e09bcc3073e372085466c181;hb=refs%2Fheads%2Fmaster;hp=7803ce2eb836b003159760ce408f97fb3acedd50;hpb=6e5d7052fe741b50e68f8614b33d3754be41415f;p=poolifier.git diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 7803ce2e..ebbefc75 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -78,7 +78,6 @@ export abstract class AbstractWorker< /** * Handler id of the `activeInterval` worker activity check. */ - // eslint-disable-next-line no-undef protected activeInterval?: NodeJS.Timeout /** @@ -378,15 +377,16 @@ export abstract class AbstractWorker< response = { status: false, error: new Error('Unknown task operation') } break } + const { status, error } = response this.sendToMainWorker({ taskFunctionOperation, - taskFunctionOperationStatus: response.status, + taskFunctionOperationStatus: status, taskFunctionProperties, - ...(!response.status && - response.error != null && { + ...(!status && + error != null && { workerError: { name: taskFunctionProperties.name, - message: this.handleError(response.error as Error | string), + message: this.handleError(error as Error | string), }, }), }) @@ -399,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 @@ -555,7 +555,7 @@ export abstract class AbstractWorker< workerError: { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion name: name!, - message: this.handleError(error), + message: this.handleError(error as Error | string), data, }, taskId,