Inspector
inspector.Session inspectorNotification event
Observes protocol notifications. Their contents can include sensitive runtime details. The lab records only a Boolean and disables the agent before disconnecting. 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): ["true"].
Formal Syntax & Structure
nodejs syntaxnodejs
session.on('inspectorNotification', listener)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| listener | Function | Notification callback. |
Return Value
Session
Emitter for listener chaining.
Working Example
Example Snippetnodejs
import { Session } from 'node:inspector';import { promisify } from 'node:util';const s = new Session();s.connect();try { let seen = false; s.on('inspectorNotification', m => { if (m.method === 'Runtime.executionContextCreated') seen = true; }); const post = promisify(s.post.bind(s)); await post('Runtime.enable'); console.log(seen); await post('Runtime.disable');}finally { s.disconnect();}