From 722a827f60eea10650958617bea72094ed702a08 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 26 Oct 2024 22:04:34 +0200 Subject: [PATCH] perf: move tasks promise map entry deletion to a micro task 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, 2 insertions(+), 2 deletions(-) diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index eeca65ee..2d573f6c 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1197,12 +1197,12 @@ export abstract class AbstractPool< } asyncResource?.emitDestroy() this.afterTaskExecutionHook(workerNodeKey, message) - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - this.promiseResponseMap.delete(taskId!) queueMicrotask(() => { this.checkAndEmitTaskExecutionFinishedEvents() // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition workerNode?.emit('taskFinished', taskId) + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + this.promiseResponseMap.delete(taskId!) if (this.opts.enableTasksQueue === true && !this.destroying) { if ( !this.isWorkerNodeBusy(workerNodeKey) && -- 2.34.1