Inspector#

Stability: 2 - Stable

The node:inspector module provides an API for interacting with the V8 inspector.

It can be accessed using:

import * as inspector from 'node:inspector/promises';
const inspector = require('node:inspector/promises');
javascript

or

import * as inspector from 'node:inspector';
const inspector = require('node:inspector');
javascript

Promises API#

Stability: 1 - Experimental

Class: inspector.Session#

The inspector.Session is used for dispatching messages to the V8 inspector back-end and receiving message responses and notifications.

new inspector.Session()#

Create a new instance of the inspector.Session class. The inspector session needs to be connected through session.connect() before the messages can be dispatched to the inspector backend.

When using Session, the object outputted by the console API will not be released, unless we performed manually Runtime.DiscardConsoleEntries command.

Event: 'inspectorNotification'#
  • Type: <Object> The notification message object

Emitted when any notification from the V8 Inspector is received.

session.on('inspectorNotification', (message) => console.log(message.method));
// Debugger.paused
// Debugger.resumed
js

Caveat Breakpoints with same-thread session is not recommended, see support of breakpoints.

It is also possible to subscribe only to notifications with specific method:

Event: <inspector-protocol-method>#