Inspector
inspector.Session.connect()
Connects the callback API session to the local inspector backend. Release the session after collecting diagnostic evidence. This lab uses an in-process session with no exposed debugger port. Never expose a debugger to untrusted clients. Tested on Node.js 22.16.0. Example output (one line per entry): ["connected"].
Formal Syntax & Structure
nodejs syntaxnodejs
session.connect()Return Value
undefined
Connects the session.
Working Example
Example Snippetnodejs
import { Session } from 'node:inspector';import { promisify } from 'node:util';const s = new Session();s.connect();try { const post = promisify(s.post.bind(s)); await post('Runtime.enable'); console.log('connected');}finally { s.disconnect();}