From f7ea68a82ca21f374a86434ecde0c8ce9a96e868 Mon Sep 17 00:00:00 2001 From: marco-ippolito Date: Sun, 24 Dec 2023 16:14:56 +0100 Subject: [PATCH] doc: deprecate process.nextTick --- doc/api/deprecations.md | 18 ++++++++++++++++++ lib/internal/process/task_queues.js | 9 +++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index a6bcbedbcd0c688..27b4a9b128a2609 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -3569,6 +3569,22 @@ Calling `Hash` class directly with `Hash()` or `new Hash()` is deprecated due to being internals, not intended for public use. Please use the [`crypto.createHash()`][] method to create Hash instances. +### DEP0180: `process.nextTick` + + + +Type: Documentation-only + +The [`process.nextTick()`][] API is deprecated due to performance +issues with async callbacks and unpredictable behavior +in promise and async/await scenarios. +Please use [`queueMicrotask()`][] instead. + [NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf [RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3 [RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4 @@ -3661,7 +3677,9 @@ Please use the [`crypto.createHash()`][] method to create Hash instances. [`process.exitCode`]: process.md#processexitcode_1 [`process.getActiveResourcesInfo()`]: process.md#processgetactiveresourcesinfo [`process.mainModule`]: process.md#processmainmodule +[`process.nextTick()`]: process.md#processnexttickcallback-args [`punycode`]: punycode.md +[`queueMicrotask()`]: globals.md#queuemicrotaskcallback [`readable.readableEnded`]: stream.md#readablereadableended [`request.abort()`]: http.md#requestabort [`request.connection`]: http.md#requestconnection diff --git a/lib/internal/process/task_queues.js b/lib/internal/process/task_queues.js index bcb5eef841dd006..7f2a94e26cd2ef9 100644 --- a/lib/internal/process/task_queues.js +++ b/lib/internal/process/task_queues.js @@ -98,8 +98,13 @@ function processTicksAndRejections() { setHasRejectionToWarn(false); } -// `nextTick()` will not enqueue any callback when the process is about to -// exit since the callback would not have a chance to be executed. +/** + * `nextTick()` will not enqueue any callback when the process is about to + * exit since the callback would not have a chance to be executed. + * @deprecated since REPLACEME + * @param {() => any} callback + * @returns {void} + */ function nextTick(callback) { validateFunction(callback, 'callback');