session.post(method[, params][, callback])


向检查器后端发送消息。当接收到响应时,将通知 callbackcallback 是一个函数,它接受两个可选参数:错误和消息特定的结果。

【Posts a message to the inspector back-end. callback will be notified when a response is received. callback is a function that accepts two optional arguments: error and message-specific result.】

session.post('Runtime.evaluate', { expression: '2 + 2' },
             (error, { result }) => console.log(result));
// Output: { 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.】

当向 V8 发送 HeapProfiler.takeHeapSnapshotHeapProfiler.stopTrackingHeapObjects 命令时,不能将 reportProgress 设置为 true

【You can not set reportProgress to true when sending a HeapProfiler.takeHeapSnapshot or HeapProfiler.stopTrackingHeapObjects command to V8.】