session.post(method[, params])
向检查器后端发布消息。
【Posts a message to the inspector back-end.】
import { Session } from 'node:inspector/promises';
try {
const session = new Session();
session.connect();
const result = await session.post('Runtime.evaluate', { expression: '2 + 2' });
console.log(result);
} catch (error) {
console.error(error);
}
// Output: { result: { type: 'number', value: 4, description: '4' } } V8 检查器协议的最新版本已发布在 Chrome 开发者工具协议查看器。
【The latest version of the V8 inspector protocol is published on the Chrome DevTools Protocol Viewer.】
Node.js 调试器支持 V8 声明的所有 Chrome DevTools 协议域。Chrome DevTools 协议域提供了与运行时代理交互的接口,用于检查应用状态并监听运行时事件。
【Node.js inspector supports all the Chrome DevTools Protocol domains declared by V8. Chrome DevTools Protocol domain provides an interface for interacting with one of the runtime agents used to inspect the application state and listen to the run-time events.】