diff --git a/doc/api/errors.md b/doc/api/errors.md index 18396f0ef8dfad..b186275807aee7 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -2053,6 +2053,11 @@ The WASI instance has already started. The `execArgv` option passed to the `Worker` constructor contains invalid flags. + +### `ERR_WORKER_NOT_RUNNING` + +An operation failed because the `Worker` instance is not currently running. + ### `ERR_WORKER_OUT_OF_MEMORY` diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index 6812e6966dae66..6ae0ada97f193a 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -674,6 +674,21 @@ inside the worker thread. If `stdout: true` was not passed to the [`Worker`][] constructor, then data will be piped to the parent thread's [`process.stdout`][] stream. +### `worker.takeHeapSnapshot()` + + +* Returns: {Promise} A promise for a Readable Stream containing + a V8 heap snapshot + +Returns a readable stream for a V8 snapshot of the current state of the Worker. +See [`v8.getHeapSnapshot()`][] for more details. + +If the Worker thread is no longer running, which may occur before the +[`'exit'` event][] is emitted, the returned `Promise` will be rejected +immediately with an [`ERR_WORKER_NOT_RUNNING`][] error. + ### `worker.terminate()`