From 684f132a0f46afc01f2e95ec004ecfd2548b8d49 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 14 Aug 2024 20:22:32 +0200 Subject: [PATCH] fix: workaround race conditions at pool destroy MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/pools/abstract-pool.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) } } -- 2.34.1