Inspector and debugging
The inspector exposes debugging and profiling interfaces to a running Node process. Debuggers can inspect values, pause execution and execute code in the inspected context, so their access boundary is highly sensitive. For local manual debugging of an owned disposable script, `node --inspect=127.0.0.1:9229 script.mjs` starts a loopback inspector, while `--inspect-brk` pauses before user code begins. Check port availability and never expose an inspector to public or untrusted networks. An in-process inspector Session can issue protocol commands without opening a listening port. Disconnect in finally. Use fixed trusted protocol calls only; avoid evaluating user-supplied code. Breakpoints can change timing, so debugger behavior is not a concurrency performance measurement. Do not attach to an unknown production process, publish inspector URLs, or leave a session connected. A loopback listener is not an authentication mechanism. Sources: https://nodejs.org/download/release/v22.16.0/docs/api/inspector.html, https://nodejs.org/docs/latest-v22.x/api/inspector.html.
Formal Syntax & Structure
new Session(); session.connect(); session.post(method, params, callback); session.disconnect()Working Example
import {url,Session} from 'node:inspector';import assert from 'node:assert/strict';assert.equal(url(),undefined);const session=new Session();session.connect();try{assert.equal(url(),undefined);console.log('in-process only');}finally{session.disconnect();}