mirror of
https://github.com/nodejs/node.git
synced 2025-05-20 19:24:39 +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>
27 lines
831 B
JavaScript
27 lines
831 B
JavaScript
// Flags: --unhandled-rejections=warn
|
|
'use strict';
|
|
const common = require('../common');
|
|
|
|
common.disableCrashOnUnhandledRejection();
|
|
|
|
const expectedValueWarning = ['Symbol()'];
|
|
const expectedPromiseWarning = ['Unhandled promise rejection. ' +
|
|
'This error originated either by throwing ' +
|
|
'inside of an async function without a catch ' +
|
|
'block, or by rejecting a promise which was ' +
|
|
'not handled with .catch(). To terminate the ' +
|
|
'node process on unhandled promise rejection, ' +
|
|
'use the CLI flag `--unhandled-rejections=strict` (see ' +
|
|
'https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). ' +
|
|
'(rejection id: 1)'];
|
|
|
|
common.expectWarning({
|
|
UnhandledPromiseRejectionWarning: [
|
|
expectedValueWarning,
|
|
expectedPromiseWarning
|
|
],
|
|
});
|
|
|
|
// Ensure this doesn't crash
|
|
Promise.reject(Symbol());
|