| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 31f809a commit 4e49d5d
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,8 +19,6 @@ const inspector = require('node:inspector'); | |||
| 19 | 19 | ||
| 20 | 20 | Deactivate the inspector. Blocks until there are no active connections. | |
| 21 | 21 | ||
| 22 | - This function is not available in [worker threads][]. | ||
| 23 | - | ||
| 24 | 22 | ## `inspector.console` | |
| 25 | 23 | ||
| 26 | 24 | * {Object} An object to send messages to the remote inspector console. | |
@@ -256,4 +254,3 @@ session.post('HeapProfiler.takeHeapSnapshot', null, (err, r) => { | |||
| 256 | 254 | [`'Debugger.paused'`]: https://chromedevtools.github.io/devtools-protocol/v8/Debugger#event-paused | |
| 257 | 255 | [`session.connect()`]: #sessionconnect | |
| 258 | 256 | [security warning]: cli.md#warning-binding-inspector-to-a-public-ipport-combination-is-insecure | |
| 259 | - [worker threads]: worker_threads.md | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,7 @@ const { | |||
| 32 | 32 | validateString, | |
| 33 | 33 | } = require('internal/validators'); | |
| 34 | 34 | const { isMainThread } = require('worker_threads'); | |
| 35 | + const { _debugEnd } = internalBinding('process_methods'); | ||
| 35 | 36 | ||
| 36 | 37 | const { | |
| 37 | 38 | Connection, | |
@@ -194,7 +195,7 @@ function inspectorWaitForDebugger() { | |||
| 194 | 195 | ||
| 195 | 196 | module.exports = { | |
| 196 | 197 | open: inspectorOpen, | |
| 197 | - close: process._debugEnd, | ||
| 198 | + close: _debugEnd, | ||
| 198 | 199 | url, | |
| 199 | 200 | waitForDebugger: inspectorWaitForDebugger, | |
| 200 | 201 | // This is dynamically added during bootstrap, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -563,7 +563,6 @@ static void Initialize(Local<Object> target, | |||
| 563 | 563 | // define various internal methods | |
| 564 | 564 | if (env->owns_process_state()) { | |
| 565 | 565 | env->SetMethod(target, "_debugProcess", DebugProcess); | |
| 566 | - env->SetMethod(target, "_debugEnd", DebugEnd); | ||
| 567 | 566 | env->SetMethod(target, "abort", Abort); | |
| 568 | 567 | env->SetMethod(target, "causeSegfault", CauseSegfault); | |
| 569 | 568 | env->SetMethod(target, "chdir", Chdir); | |
@@ -576,6 +575,7 @@ static void Initialize(Local<Object> target, | |||
| 576 | 575 | env->SetMethod(target, "cpuUsage", CPUUsage); | |
| 577 | 576 | env->SetMethod(target, "resourceUsage", ResourceUsage); | |
| 578 | 577 | ||
| 578 | + env->SetMethod(target, "_debugEnd", DebugEnd); | ||
| 579 | 579 | env->SetMethod(target, "_getActiveRequests", GetActiveRequests); | |
| 580 | 580 | env->SetMethod(target, "_getActiveRequestsInfo", GetActiveRequestsInfo); | |
| 581 | 581 | env->SetMethod(target, "_getActiveHandles", GetActiveHandles); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,34 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + common.skipIfInspectorDisabled(); | ||
| 5 | + const { isMainThread, Worker } = require('worker_threads'); | ||
| 6 | + const assert = require('assert'); | ||
| 7 | + const inspector = require('inspector'); | ||
| 8 | + | ||
| 9 | + if (!isMainThread) { | ||
| 10 | + // Verify the inspector api on the worker thread. | ||
| 11 | + assert.strictEqual(inspector.url(), undefined); | ||
| 12 | + | ||
| 13 | + inspector.open(0, undefined, false); | ||
| 14 | + const wsUrl = inspector.url(); | ||
| 15 | + assert(wsUrl.startsWith('ws://')); | ||
| 16 | + inspector.close(); | ||
| 17 | + assert.strictEqual(inspector.url(), undefined); | ||
| 18 | + return; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + // Open inspector on the main thread first. | ||
| 22 | + inspector.open(0, undefined, false); | ||
| 23 | + const wsUrl = inspector.url(); | ||
| 24 | + assert(wsUrl.startsWith('ws://')); | ||
| 25 | + | ||
| 26 | + const worker = new Worker(__filename); | ||
| 27 | + worker.on('exit', common.mustCall((code) => { | ||
| 28 | + assert.strictEqual(code, 0); | ||
| 29 | + | ||
| 30 | + // Verify inspector on the main thread is still active. | ||
| 31 | + assert.strictEqual(inspector.url(), wsUrl); | ||
| 32 | + inspector.close(); | ||
| 33 | + assert.strictEqual(inspector.url(), undefined); | ||
| 34 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments