From: Jérôme Benoit Date: Wed, 14 Aug 2024 18:22:32 +0000 (+0200) Subject: fix: workaround race conditions at pool destroy X-Git-Tag: v4.2.2~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=684f132a0f46afc01f2e95ec004ecfd2548b8d49;p=poolifier.git fix: workaround race conditions at pool destroy Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 8aab6695..a1b6b02e 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -2163,7 +2163,9 @@ export abstract class AbstractPool< }) } } - workerNode.emit('taskFinished', taskId) + // FIXME: cannot be theoretically undefined. Schedule in the next tick to avoid race conditions? + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + workerNode?.emit('taskFinished', taskId) } }