mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
promise: emit error on domain unhandled rejections
PR-URL: https://github.com/nodejs/node/pull/36082 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
2fd22353ea
commit
cd3134029e
3 files changed
+24
-33
No files matched your search
@@ -126,3 +126,13 @@ process.on('warning', common.mustNotCall());
|
||||
}));
|
||||
}));
|
||||
}
|
||||
{
|
||||
// Unhandled rejections become errors on the domain
|
||||
const d = domain.create();
|
||||
d.on('error', common.mustCall((e) => {
|
||||
assert.strictEqual(e.message, 'foo');
|
||||
}));
|
||||
d.run(common.mustCall(() => {
|
||||
Promise.reject(new Error('foo'));
|
||||
}));
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const domain = require('domain');
|
||||
const { inspect } = require('util');
|
||||
|
||||
common.disableCrashOnUnhandledRejection();
|
||||
@@ -622,30 +621,6 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest(
|
||||
'Promise unhandledRejection handler does not interfere with domain' +
|
||||
' error handlers being given exceptions thrown from nextTick.',
|
||||
function(done) {
|
||||
const d = domain.create();
|
||||
let domainReceivedError;
|
||||
d.on('error', function(e) {
|
||||
domainReceivedError = e;
|
||||
});
|
||||
d.run(function() {
|
||||
const e = new Error('error');
|
||||
const domainError = new Error('domain error');
|
||||
onUnhandledSucceed(done, function(reason, promise) {
|
||||
assert.strictEqual(reason, e);
|
||||
assert.strictEqual(domainReceivedError, domainError);
|
||||
});
|
||||
Promise.reject(e);
|
||||
process.nextTick(function() {
|
||||
throw domainError;
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
asyncTest('nextTick is immediately scheduled when called inside an event' +
|
||||
' handler', function(done) {
|
||||
clean();
|
||||
|
||||
Reference in new issue
Block a user