1// Check that abrupt termination when async call stack recording is enabled 2// does not segfault the process. 3'use strict'; 4const common = require('../common'); 5common.skipIfInspectorDisabled(); 6common.skipIf32Bits(); 7 8const { strictEqual } = require('assert'); 9const eyecatcher = 'nou, houdoe he?'; 10 11if (process.argv[2] === 'child') { 12 common.disableCrashOnUnhandledRejection(); 13 const { Session } = require('inspector'); 14 const { promisify } = require('util'); 15 const { internalBinding } = require('internal/test/binding'); 16 const { registerAsyncHook } = internalBinding('inspector'); 17 (async () => { 18 let enabled = 0; 19 registerAsyncHook(() => ++enabled, () => {}); 20 const session = new Session(); 21 session.connect(); 22 session.post = promisify(session.post); 23 await session.post('Debugger.enable'); 24 strictEqual(enabled, 0); 25 await session.post('Debugger.setAsyncCallStackDepth', { maxDepth: 42 }); 26 strictEqual(enabled, 1); 27 throw new Error(eyecatcher); 28 })().finally(common.mustCall()); 29} else { 30 const { spawnSync } = require('child_process'); 31 const options = { encoding: 'utf8' }; 32 const proc = spawnSync( 33 process.execPath, ['--expose-internals', __filename, 'child'], options); 34 strictEqual(proc.status, 0); 35 strictEqual(proc.signal, null); 36 strictEqual(proc.stderr.includes(eyecatcher), true); 37} 38