Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2466,7 +2466,8 @@ changes:
Type: Documentation-only (supports [`--pending-deprecation`][])

The `process._tickCallback` property was never documented as
an officially supported API.
an officially supported API. Please use `process.runNextTicks`
instead.

### DEP0135: `WriteStream.open()` and `ReadStream.open()` are internal
<!-- YAML
Expand Down
38 changes: 38 additions & 0 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -3005,6 +3005,42 @@ console.log(resourceUsage());
*/
```

## `process.runNextTicks()`
<!-- YAML
added: REPLACEME
-->

Ensures all tasks in the V8 micro-task queue have completed. This will cause any
callback passed to [`process.nextTick()`][], [`queueMicrotask()`][] or to
[`.then()`][`promise.then()`] or [`.catch()`][`promise.catch()`] of an
immediately resolving or rejecting promise to be executed.

```mjs
import { runNextTicks } from 'process';

let value = '';

queueMicrotask(() => {
value = 'foo';
});

runNextTicks();

console.log(value); // 'foo'
```

```cjs
let value = '';

queueMicrotask(() => {
value = 'foo';
});

process.runNextTicks();

console.log(value); // 'foo'
```

## `process.send(message[, sendHandle[, options]][, callback])`
<!-- YAML
added: v0.5.9
Expand Down Expand Up @@ -3720,8 +3756,10 @@ cases:
[`process.hrtime()`]: #processhrtimetime
[`process.hrtime.bigint()`]: #processhrtimebigint
[`process.kill()`]: #processkillpid-signal
[`process.nextTick()`]: #process_nexttick_callback_args
[`process.setUncaughtExceptionCaptureCallback()`]: #processsetuncaughtexceptioncapturecallbackfn
[`promise.catch()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch
[`promise.then()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then
[`queueMicrotask()`]: globals.md#queuemicrotaskcallback
[`readable.read()`]: stream.md#readablereadsize
[`require()`]: globals.md#require
Expand Down
7 changes: 3 additions & 4 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,9 @@ process.emitWarning = emitWarning;
{
const { nextTick, runNextTicks } = setupTaskQueue();
process.nextTick = nextTick;
// Used to emulate a tick manually in the JS land.
// A better name for this function would be `runNextTicks` but
// it has been exposed to the process object so we keep this legacy name
// TODO(joyeecheung): either remove it or make it public
process.runNextTicks = runNextTicks;

// TODO: Deprecate when usage drops
process._tickCallback = runNextTicks;

const { getTimerCallbacks } = require('internal/timers');
Expand Down