| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a9f9a3d commit e611ccd
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -415,8 +415,8 @@ changes: | |||
| 415 | 415 | description: The API is exposed in the worker threads. | |
| 416 | 416 | --> | |
| 417 | 417 | ||
| 418 | - Attempts to close all remaining connections, blocking the event loop until all | ||
| 419 | - are closed. Once all connections are closed, deactivates the inspector. | ||
| 418 | + Deactivates the inspector. If there are active connections, they are forcibly | ||
| 419 | + terminated. Blocks until the inspector server has fully stopped. | ||
| 420 | 420 | ||
| 421 | 421 | ### `inspector.console` | |
| 422 | 422 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,35 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + common.skipIfInspectorDisabled(); | ||
| 4 | + | ||
| 5 | + const assert = require('assert'); | ||
| 6 | + const { NodeInstance } = require('../common/inspector-helper.js'); | ||
| 7 | + | ||
| 8 | + // Verify that inspector.close() forcibly terminates active WebSocket | ||
| 9 | + // connections without waiting for the client to disconnect. | ||
| 10 | + | ||
| 11 | + async 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 | + | ||
| 35 | + test().then(common.mustCall()); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments