Skip to content

Commit

Permalink
doc: deprecate process.nextTick
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ippolito committed Dec 24, 2023
1 parent ee61c2c commit f7ea68a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
18 changes: 18 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/51280
description: Documentation-only deprecation.
-->

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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions lib/internal/process/task_queues.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit f7ea68a

Please sign in to comment.