diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 69913686a8028d..af28278f23c624 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2484,6 +2484,20 @@ The legacy HTTP parser, used by default in versions of Node.js prior to 12.0.0, is deprecated. This deprecation applies to users of the [`--http-parser=legacy`][] command-line flag. + +### DEP0XXX: worker.terminate() with callback + + +Type: Runtime + +Passing a callback to [`worker.terminate()`][] is deprecated. Use the returned +`Promise` instead, or a listener to the worker’s `'exit'` event. + [`--http-parser=legacy`]: cli.html#cli_http_parser_library [`--pending-deprecation`]: cli.html#cli_pending_deprecation [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size @@ -2576,6 +2590,7 @@ is deprecated. This deprecation applies to users of the [`util.types`]: util.html#util_util_types [`util`]: util.html [`worker.exitedAfterDisconnect`]: cluster.html#cluster_worker_exitedafterdisconnect +[`worker.terminate()`]: worker_threads.html#worker_threads_worker_terminate [`zlib.bytesWritten`]: zlib.html#zlib_zlib_byteswritten [Legacy URL API]: url.html#url_legacy_url_api [NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index 27d4fb2a6a62fb..39d948ccea7108 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -617,24 +617,23 @@ 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.terminate([callback]) +### worker.terminate() -* `callback` {Function} - * `err` {Error} - * `exitCode` {integer} +* Returns: {Promise} Stop all JavaScript execution in the worker thread as soon as possible. -`callback` is an optional function that is invoked once this operation is known -to have completed. - -**Warning**: Currently, not all code in the internals of Node.js is prepared to -expect termination at arbitrary points in time and may crash if it encounters -that condition. Consequently, only call `.terminate()` if it is known that the -Worker thread is not accessing Node.js core modules other than what is exposed -in the `worker` module. +Returns a Promise for the exit code that is fulfilled when the +[`'exit'` event][] is emitted. ### worker.threadId