worker.getHeapSnapshot([options])


  • options <Object>
    • exposeInternals <boolean> 如果为 true,在堆快照中公开内部信息。 默认值: false
    • exposeNumericValues <boolean> 如果为 true,则在人工字段中显示数值。默认值: false
  • 返回:<Promise> 一个包含 V8 堆快照的可读取流的 Promise

返回一个可读流,用于获取当前 Worker 状态的 V8 快照。更多详情请参见 v8.getHeapSnapshot()

【Returns a readable stream for a V8 snapshot of the current state of the Worker. See v8.getHeapSnapshot() for more details.】

如果 Worker 线程不再运行,这可能会在 'exit' 事件 发出之前发生,返回的 Promise 会立即以 ERR_WORKER_NOT_RUNNING 错误被拒绝。

【If the Worker thread is no longer running, which may occur before the 'exit' event is emitted, the returned Promise is rejected immediately with an ERR_WORKER_NOT_RUNNING error.】