fix: ensure event is emitted before task promise rejection
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 21 Jun 2023 22:12:35 +0000 (00:12 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 21 Jun 2023 22:12:35 +0000 (00:12 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/abstract-pool.ts

index 9af3d707c35088356aae00f6192c1a716e9a8bf9..058b43b8a37104b29d1d15978613c42735072547 100644 (file)
@@ -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)
           }