node/test/parallel/test-async-wrap-pop-id-during-load.js
Anna Henningsen e095e645e5 src: print exceptions from PromiseRejectCallback
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>
2019-09-16 05:53:43 +02:00

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);