MCPcopy Index your code
hub / github.com/nodejs/node / test

Function test

test/parallel/test-inspector-close-terminate-connections.js:11–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9// connections without waiting for the client to disconnect.
10
11async function test() {
12 const script = `
13 const inspector = require('inspector');
14 inspector.close();
15 process.exit(42);
16 `;
17
18 const instance = new NodeInstance(['--inspect-brk=0'], script);
19 const session = await instance.connectInspectorSession();
20
21 // Enable Runtime domain and wait for an event to confirm the session is live.
22 await session.send({ method: 'Runtime.enable' });
23 await session.waitForNotification('Runtime.executionContextCreated');
24
25 // Resume execution so the script calls inspector.close().
26 await session.send({ method: 'Runtime.runIfWaitingForDebugger' });
27
28 // The server should forcibly disconnect us.
29 await session.waitForServerDisconnect();
30
31 const { exitCode } = await instance.expectShutdown();
32 assert.strictEqual(exitCode, 42);
33}
34
35test().then(common.mustCall());

Calls 5

expectShutdownMethod · 0.95
waitForNotificationMethod · 0.80
sendMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…