Inspector

inspector.Session.disconnect()

Closes a session and drops its inspector state. Reconnecting requires enabling any diagnostic agents again. 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): ["ERR_INSPECTOR_NOT_CONNECTED"].

Formal Syntax & Structure

nodejs syntaxnodejs
session.disconnect()

Return Value

undefined

Closes the session.

Working Example

Example Snippetnodejs
import { Session } from 'node:inspector';const s = new Session();s.connect();s.disconnect();try {    s.post('Runtime.enable');}catch (e) {    console.log(e.code);}s.connect();s.disconnect();
Node.js Reference