From: Jérôme Benoit Date: Sat, 26 Oct 2024 20:04:34 +0000 (+0200) Subject: perf: move tasks promise map entry deletion to a micro task X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=722a827f60eea10650958617bea72094ed702a08;p=poolifier.git perf: move tasks promise map entry deletion to a micro task Signed-off-by: Jérôme Benoit --- 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) &&