summaryrefslogtreecommitdiff
path: root/src/node.js
diff options
context:
space:
mode:
authorVladimir Kurchatkin <vladimir.kurchatkin@gmail.com>2015-06-11 23:08:17 +0300
committerVladimir Kurchatkin <vladimir.kurchatkin@gmail.com>2015-06-13 00:24:24 +0300
commita2516570589db22ffa142644b0e633f22b293c32 (patch)
tree2294ebf74994395c241882abfb941a0e9213cdb6 /src/node.js
parent03ce84dfa13a1cc075bb45772a8a566213148939 (diff)
downloadnode-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/node.js')
-rw-r--r--src/node.js12
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');
});