diff options
author | Vladimir Kurchatkin <vladimir.kurchatkin@gmail.com> | 2015-06-11 23:08:17 +0300 |
---|---|---|
committer | Vladimir Kurchatkin <vladimir.kurchatkin@gmail.com> | 2015-06-13 00:24:24 +0300 |
commit | a2516570589db22ffa142644b0e633f22b293c32 (patch) | |
tree | 2294ebf74994395c241882abfb941a0e9213cdb6 /src | |
parent | 03ce84dfa13a1cc075bb45772a8a566213148939 (diff) | |
download | node-new-a2516570589db22ffa142644b0e633f22b293c32.tar.gz |
node: mark promises as handled as soon as possible
Fixes: https://github.com/nodejs/io.js/issues/1912
PR-URL: https://github.com/nodejs/io.js/pull/1952
Reviewed-By: Domenic Denicola <d@domenic.me>
Reviewed-By: Petka Antonov <petka_antonov@hotmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/node.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/node.js b/src/node.js index 25164784cf..292c7b2213 100644 --- a/src/node.js +++ b/src/node.js @@ -515,8 +515,12 @@ var hasBeenNotified = hasBeenNotifiedProperty.get(promise); if (hasBeenNotified !== undefined) { hasBeenNotifiedProperty.delete(promise); - if (hasBeenNotified === true) - process.emit('rejectionHandled', promise); + if (hasBeenNotified === true) { + process.nextTick(function() { + process.emit('rejectionHandled', promise); + }); + } + } } @@ -524,9 +528,7 @@ if (event === promiseRejectEvent.unhandled) unhandledRejection(promise, reason); else if (event === promiseRejectEvent.handled) - process.nextTick(function() { - rejectionHandled(promise); - }); + rejectionHandled(promise); else NativeModule.require('assert').fail('unexpected PromiseRejectEvent'); }); |