mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 23:56:58 +00:00

This is a semver-major change that resolves DEP0018. All users that have set an unhandledRejection hook or set a non-default value for the --unhandled-rejections flag will see no change in behavior after this change. Refs: https://nodejs.org/dist/latest/docs/api/deprecations.html#deprecations_dep0018_unhandled_promise_rejections PR-URL: https://github.com/nodejs/node/pull/33021 Fixes: https://github.com/nodejs/node/issues/20392 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Mary Marchini <oss@mmarchini.me> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
21 lines
595 B
JavaScript
21 lines
595 B
JavaScript
// Flags: --unhandled-rejections=warn
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
// Verify that --unhandled-rejections=warn works fine
|
|
|
|
new Promise(() => {
|
|
throw new Error('One');
|
|
});
|
|
|
|
Promise.reject('test');
|
|
|
|
// Unhandled rejections trigger two warning per rejection. One is the rejection
|
|
// reason and the other is a note where this warning is coming from.
|
|
process.on('warning', common.mustCall(4));
|
|
process.on('uncaughtException', common.mustNotCall('uncaughtException'));
|
|
process.on('rejectionHandled', common.mustNotCall('rejectionHandled'));
|
|
|
|
setTimeout(common.mustCall(), 2);
|