From aa0665719e090b6fcd4e6a58b587c7d3d484e1b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 19 Aug 2025 15:49:36 +0200 Subject: [PATCH] fix: handle more task function declaration signatures MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/worker/abstract-worker.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 3ea7aadec..0741963c5 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -342,7 +342,7 @@ export abstract class AbstractWorker< response = this.addTaskFunction(taskFunctionProperties.name, { // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func, @typescript-eslint/no-unsafe-call taskFunction: new Function( - `return ${taskFunction}` + `return (${taskFunction})` )() as TaskFunction, ...(taskFunctionProperties.priority != null && { priority: taskFunctionProperties.priority, @@ -360,7 +360,10 @@ export abstract class AbstractWorker< break default: response = { - error: new Error('Unknown task operation'), + error: new Error( + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + `Unknown task function operation: ${taskFunctionOperation!}` + ), status: false, } break @@ -432,8 +435,7 @@ export abstract class AbstractWorker< data, name, ...this.handleError( - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - new Error(`Task function '${name!}' not found`) + new Error(`Task function '${taskFunctionName}' not found`) ), }, }) @@ -713,7 +715,7 @@ export abstract class AbstractWorker< private stopCheckActive (): void { if (this.activeInterval != null) { clearInterval(this.activeInterval) - delete this.activeInterval + this.activeInterval = undefined } } -- 2.43.0