mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 23:52:40 +00:00

Previously, leaving the exception lying around would leave the JS engine in an invalid state, as it was not expecting exceptions to be thrown from the C++ `PromiseRejectCallback`, and lead to hard crashes under some conditions (e.g. with coverage enabled). PR-URL: https://github.com/nodejs/node/pull/29513 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
27 lines
716 B
JavaScript
27 lines
716 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
if (process.argv[2] === 'async') {
|
|
common.disableCrashOnUnhandledRejection();
|
|
async function fn() {
|
|
fn();
|
|
throw new Error();
|
|
}
|
|
return (async function() { await fn(); })();
|
|
}
|
|
|
|
const assert = require('assert');
|
|
const { spawnSync } = require('child_process');
|
|
|
|
const ret = spawnSync(
|
|
process.execPath,
|
|
['--stack_size=150', __filename, 'async'],
|
|
{ maxBuffer: Infinity }
|
|
);
|
|
assert.strictEqual(ret.status, 0,
|
|
`EXIT CODE: ${ret.status}, STDERR:\n${ret.stderr}`);
|
|
const stderr = ret.stderr.toString('utf8', 0, 2048);
|
|
assert.ok(!/async.*hook/i.test(stderr));
|
|
assert.ok(stderr.includes('Maximum call stack size exceeded'), stderr);
|