From: Jérôme Benoit Date: Wed, 21 Jun 2023 22:12:35 +0000 (+0200) Subject: fix: ensure event is emitted before task promise rejection X-Git-Tag: v2.6.4~43 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=cd9580e7fd7edad1758e8797f6168c05d6701621;p=poolifier.git fix: ensure event is emitted before task promise rejection Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 9af3d707..058b43b8 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -767,10 +767,10 @@ export abstract class AbstractPool< const promiseResponse = this.promiseResponseMap.get(message.id) if (promiseResponse != null) { if (message.taskError != null) { - promiseResponse.reject(message.taskError.message) if (this.emitter != null) { this.emitter.emit(PoolEvents.taskError, message.taskError) } + promiseResponse.reject(message.taskError.message) } else { promiseResponse.resolve(message.data as Response) }