mirror of
https://github.com/nodejs/node.git
synced 2025-05-03 11:12:55 +00:00

Use the --unhandled-rejections=none CLI flag instead. PR-URL: https://github.com/nodejs/node/pull/38210 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
27 lines
735 B
JavaScript
27 lines
735 B
JavaScript
// Flags: --unhandled-rejections=warn
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
// Verify that ignoring unhandled rejection works fine and that no warning is
|
|
// logged.
|
|
|
|
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.mustCall(2));
|
|
|
|
process.on('unhandledRejection', (reason, promise) => {
|
|
// Handle promises but still warn!
|
|
promise.catch(() => {});
|
|
});
|
|
|
|
setTimeout(common.mustCall(), 2);
|