Skip to content

Commit dc6eb8d

Browse files
lib: deprecate process.nextTick
1 parent ee61c2c commit dc6eb8d

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

doc/api/deprecations.md

+18
Original file line numberDiff line numberDiff line change
@@ -3569,6 +3569,22 @@ Calling `Hash` class directly with `Hash()` or `new Hash()` is
35693569
deprecated due to being internals, not intended for public use.
35703570
Please use the [`crypto.createHash()`][] method to create Hash instances.
35713571

3572+
### DEP0180: `process.nextTick`
3573+
3574+
<!-- YAML
3575+
changes:
3576+
- version: REPLACEME
3577+
pr-url: https://github.com/nodejs/node/pull/51280
3578+
description: Documentation-only deprecation.
3579+
-->
3580+
3581+
Type: Documentation-only
3582+
3583+
The [`process.nextTick()`][] API is deprecated due to performance
3584+
issues with async callbacks and unpredictable behavior
3585+
in promise and async/await scenarios.
3586+
Please use [`queueMicrotask()`][] instead.
3587+
35723588
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
35733589
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
35743590
[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.
36613677
[`process.exitCode`]: process.md#processexitcode_1
36623678
[`process.getActiveResourcesInfo()`]: process.md#processgetactiveresourcesinfo
36633679
[`process.mainModule`]: process.md#processmainmodule
3680+
[`process.nextTick()`]: process.md#processnexttickcallback-args
36643681
[`punycode`]: punycode.md
3682+
[`queueMicrotask()`]: globals.md#queuemicrotaskcallback
36653683
[`readable.readableEnded`]: stream.md#readablereadableended
36663684
[`request.abort()`]: http.md#requestabort
36673685
[`request.connection`]: http.md#requestconnection

lib/internal/process/task_queues.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,13 @@ function processTicksAndRejections() {
9898
setHasRejectionToWarn(false);
9999
}
100100

101-
// `nextTick()` will not enqueue any callback when the process is about to
102-
// exit since the callback would not have a chance to be executed.
101+
/**
102+
* `nextTick()` will not enqueue any callback when the process is about to
103+
* exit since the callback would not have a chance to be executed.
104+
* @deprecated since REPLACEME
105+
* @param {() => any} callback
106+
* @returns {void}
107+
*/
103108
function nextTick(callback) {
104109
validateFunction(callback, 'callback');
105110

0 commit comments

Comments
 (0)