X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Fabstract-worker.ts;h=431354677c17b4da4f21035ba56b2e09ff98b34e;hb=bcf85f7f89db68417a18393ad629fc26a2383841;hp=311a56ad60e00684835e89ef0507d60f0c9d4432;hpb=e2898b4f0f2e355bbe65974e1789cbe0c59168ba;p=poolifier.git diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 311a56ad..43135467 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -100,6 +100,7 @@ export abstract class AbstractWorker< this.checkTaskFunctions(taskFunctions) this.checkWorkerOptions(this.opts) if (!this.isMain) { + // Should be once() but Node.js on windows has a bug that prevents it from working this.getMainWorker().on('message', this.handleReadyMessage.bind(this)) } } @@ -367,13 +368,13 @@ export abstract class AbstractWorker< * * @param message - The kill message. */ - protected handleKillMessage (message: MessageValue): void { + protected handleKillMessage (_message: MessageValue): void { this.stopCheckActive() if (isAsyncFunction(this.opts.killHandler)) { (this.opts.killHandler?.() as Promise) .then(() => { this.sendToMainWorker({ kill: 'success' }) - return null + return undefined }) .catch(() => { this.sendToMainWorker({ kill: 'failure' }) @@ -404,7 +405,7 @@ export abstract class AbstractWorker< private checkMessageWorkerId (message: MessageValue): void { if (message.workerId == null) { throw new Error('Message worker id is not set') - } else if (message.workerId != null && message.workerId !== this.id) { + } else if (message.workerId !== this.id) { throw new Error( `Message worker id ${message.workerId} does not match the worker id ${this.id}` )