diff --git a/doc/api/errors.md b/doc/api/errors.md index 34ea548cba62c2..4a3c8e3c8d7520 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -2069,6 +2069,11 @@ The `Worker` initialization failed. 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 f9fb8cf4d62d9b..c69d5bfc0f9e2c 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -684,6 +684,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()`