Skip to content

fix(ext/node): align nextTick ordering in ESM#34085

Merged
bartlomieju merged 1 commit into
mainfrom
fix-nexttick-microtask-order
May 15, 2026
Merged

fix(ext/node): align nextTick ordering in ESM#34085
bartlomieju merged 1 commit into
mainfrom
fix-nexttick-microtask-order

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

Closes #34052

This updates module evaluation so promise and queueMicrotask jobs queued during top-level ESM evaluation run before process.nextTick, matching Node ESM behavior. It also drains the nextTick queue at the end of main CJS loading to preserve Node CJS entrypoint ordering.

Tests added for both ESM and CJS ordering.

Verified:

  • ./target/debug/deno run -A tests/specs/node/next_tick_microtask_order/main.mjs
  • ./target/debug/deno run -A tests/specs/node/next_tick_microtask_order/main.cjs
  • ./x test-spec next_tick_microtask_order
  • cargo test -p deno_core nexttick
  • cargo test -p deno_core test_tla_with_tick_scheduled_no_hang
  • cargo fmt --check
  • ./target/debug/deno fmt --check ext/node/polyfills/01_require.js tests/specs/node/next_tick_microtask_order/__test__.jsonc tests/specs/node/next_tick_microtask_order/main.mjs tests/specs/node/next_tick_microtask_order/main.cjs
  • git diff --check

@bartlomieju bartlomieju changed the title fix(node): align nextTick ordering in ESM fix(ext/node): align nextTick ordering in ESM May 15, 2026
@bartlomieju
bartlomieju merged commit 3090d6f into main May 15, 2026
137 checks passed
@bartlomieju
bartlomieju deleted the fix-nexttick-microtask-order branch May 15, 2026 19:22
littledivy pushed a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
Closes denoland#34052

This updates module evaluation so promise and `queueMicrotask` jobs
queued during top-level ESM evaluation run before `process.nextTick`,
matching Node ESM behavior. It also drains the nextTick queue at the end
of main CJS loading to preserve Node CJS entrypoint ordering.

Tests added for both ESM and CJS ordering.
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.

process.nextTick() ordering differs from Node.js with Promise microtasks and queueMicrotask

1 participant