Skip to content

Report process.nextTick() as a microtask to the dependency graph - #243

Merged
Domiii merged 1 commit into
dominik/node-dg-eventsfrom
dominik/node-dg-ticks
Nov 17, 2026
Merged

Domiii merged 1 commit into
dominik/node-dg-eventsfrom
dominik/node-dg-ticks

Conversation

@Domiii

@Domiii Domiii commented Nov 17, 2026 •

Copy link
Copy Markdown

🤖

Summary

  • Problem: process.nextTick() is reported as a generic async op, asyncInit{TickObject} -scheduler-> asyncCallback.
    • The backend treats asyncCallback after asyncInit as a new task with a scheduling delay.
      • limitingPath.ts isDependencyScheduling.
    • A tick is not a new task. The tick queue drains in the same turn as the code that queued it, before any other task, as microtasks do.
  • Solution: report ticks as microtasks, enqueueMicrotask -scheduler-> runMicrotask.
    • These are the kinds node#240 uses for queueMicrotask(). Chromium uses them for microtasks.
    • workerd also reports its nextTick with these kinds.

Change

  • nextTick initializes its op with the kMicrotask class instead of kGeneric.
  • The window, destroy and gates are unchanged.

Prod behavior

  • Unrecorded runs: unchanged, one false-boolean check per tick.
  • Recordings: unchanged, one binding call per tick init.
  • No JS-visible change.

Data

@Domiii
Domiii added this pull request to stack #245 November 17, 2026 17:15
@Domiii Domiii self-assigned this Nov 17, 2026
@Domiii
Domiii force-pushed the dominik/node-dg-ticks branch from 141311e to d90b0db Compare November 17, 2026 17:32
process.nextTick() callbacks are reported with the kinds of
queueMicrotask(): enqueueMicrotask -scheduler-> runMicrotask, instead of
asyncInit{TickObject} -scheduler-> asyncCallback.

The tick queue drains in the same turn as the code that queued it, before
any other task, as microtasks do. The backend treats asyncCallback after
asyncInit as a task boundary with a scheduling delay, which a tick does not
have.

Prod behavior: unchanged. The same single JS boolean check per tick when
unrecorded, and one binding call per tick when recording.
@Domiii
Domiii force-pushed the dominik/node-dg-ticks branch from d90b0db to 83c40b4 Compare November 17, 2026 17:51
@Domiii
Domiii merged commit ecb3542 into main Nov 17, 2026
3 checks passed
@Domiii
Domiii deleted the dominik/node-dg-ticks branch November 17, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant