From: Jérôme Benoit Date: Wed, 14 Aug 2024 18:07:43 +0000 (+0200) Subject: fix: fix race condition at task response handling during pool destroy X-Git-Tag: v4.2.2~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b28533a38f984b6a28edf6edc53940bd85f24200;p=poolifier.git fix: fix race condition at task response handling during pool destroy Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 77ce43c3..8aab6695 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -2146,7 +2146,6 @@ export abstract class AbstractPool< this.afterTaskExecutionHook(workerNodeKey, message) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.promiseResponseMap.delete(taskId!) - workerNode.emit('taskFinished', taskId) if (this.opts.enableTasksQueue === true && !this.destroying) { const workerNodeTasksUsage = workerNode.usage.tasks if ( @@ -2164,6 +2163,7 @@ export abstract class AbstractPool< }) } } + workerNode.emit('taskFinished', taskId) } }