mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 22:31:35 +00:00

The unhandled promise rejection warning uses a template literal and prints the reason a promise was rejected. If rejecting with a symbol, the symbol failed to convert to a string and the process crashed. Now, symbols are casted to strings and the process does not crash. Fixes: https://github.com/nodejs/node/issues/11637 PR-URL: https://github.com/nodejs/node/pull/11640 Reviewed-By: Anna Henningsen <anna@addaleax.net>
19 lines
732 B
JavaScript
19 lines
732 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
|
|
const expectedDeprecationWarning = 'Unhandled promise rejections are ' +
|
|
'deprecated. In the future, promise ' +
|
|
'rejections that are not handled will ' +
|
|
'terminate the Node.js process with a ' +
|
|
'non-zero exit code.';
|
|
const expectedPromiseWarning = 'Unhandled promise rejection (rejection id: ' +
|
|
'1): Symbol()';
|
|
|
|
common.expectWarning({
|
|
DeprecationWarning: expectedDeprecationWarning,
|
|
UnhandledPromiseRejectionWarning: expectedPromiseWarning,
|
|
});
|
|
|
|
// ensure this doesn't crash
|
|
Promise.reject(Symbol());
|