• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Flags: --unhandled-rejections=warn
2'use strict';
3
4const common = require('../common');
5
6common.disableCrashOnUnhandledRejection();
7
8// Verify that ignoring unhandled rejection works fine and that no warning is
9// logged.
10
11new Promise(() => {
12  throw new Error('One');
13});
14
15Promise.reject('test');
16
17// Unhandled rejections trigger two warning per rejection. One is the rejection
18// reason and the other is a note where this warning is coming from.
19process.on('warning', common.mustCall(4));
20process.on('uncaughtException', common.mustNotCall('uncaughtException'));
21process.on('rejectionHandled', common.mustCall(2));
22
23process.on('unhandledRejection', (reason, promise) => {
24  // Handle promises but still warn!
25  promise.catch(() => {});
26});
27
28setTimeout(common.mustCall(), 2);
29