node/test/sequential/test-inspector-async-call-stack-abort.js
Dan Fabulich 3b10f7f933
process: change default --unhandled-rejections=throw
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>
2020-09-22 12:29:32 -07:00

37 lines
1.3 KiB
JavaScript

// Check that abrupt termination when async call stack recording is enabled
// does not segfault the process.
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIf32Bits();
const { strictEqual } = require('assert');
const eyecatcher = 'nou, houdoe he?';
if (process.argv[2] === 'child') {
const { Session } = require('inspector');
const { promisify } = require('util');
const { internalBinding } = require('internal/test/binding');
const { registerAsyncHook } = internalBinding('inspector');
(async () => {
let enabled = 0;
registerAsyncHook(() => ++enabled, () => {});
const session = new Session();
session.connect();
session.post = promisify(session.post);
await session.post('Debugger.enable');
strictEqual(enabled, 0);
await session.post('Debugger.setAsyncCallStackDepth', { maxDepth: 42 });
strictEqual(enabled, 1);
throw new Error(eyecatcher);
})().finally(common.mustCall());
} else {
const { spawnSync } = require('child_process');
const options = { encoding: 'utf8' };
const proc = spawnSync(
process.execPath, ['--expose-internals', __filename, 'child'], options);
strictEqual(proc.status, 1);
strictEqual(proc.signal, null);
strictEqual(proc.stderr.includes(eyecatcher), true);
}