Skip to content

vm: support shared microtask queues - #65582

Open
kairosci wants to merge 2 commits into
nodejs:mainfrom
kairosci:feat/vm-shared-microtask-queue
Open

vm: support shared microtask queues#65582
kairosci wants to merge 2 commits into
nodejs:mainfrom
kairosci:feat/vm-shared-microtask-queue

Conversation

@kairosci

Copy link
Copy Markdown

This PR introduces vm.MicrotaskQueue and the options.microtaskQueue setting in node:vm, allowing multiple contexts to share an explicit V8 microtask queue and giving authors synchronous control over draining via queue.runMicrotasks(). This enables standards-compliant event loop integration such as HTML window and same-agent iframe microtask checkpointing without premature queue draining.

Fixes: #65555

Add `vm.MicrotaskQueue` and `options.microtaskQueue` to allow multiple
contexts to share an explicit V8 microtask queue and let users control
synchronous checkpoint draining.

Fixes: nodejs#65555
Signed-off-by: Alessio Attilio <alessio.attilio@protonmail.com>
Assisted-by: Antigravity
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Aug 27, 2026
Comment thread doc/api/vm.md
Document how options.microtaskQueue and options.microtaskMode interact
across createContext, runInNewContext, and script.runInNewContext.
Update receiver type error expectation for runMicrotasks and add test
coverage for runInNewContext with microtask queues.

Signed-off-by: Alessio Attilio <alessio.attilio@protonmail.com>
Assisted-by: Antigravity
@MikeMcC399

Copy link
Copy Markdown
Contributor

This PR is failing linting tests. See the comments in the tests for more detail.

See also Pull requests > Step 6: Test with further details in the linked document section BUILDING > Running tests.

To run the linter, use make lint / vcbuild lint. It will lint JavaScript, C++, and Markdown files.

@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.45455% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.06%. Comparing base (abb365a) to head (ef18630).
⚠️ Report is 220 commits behind head on main.

Files with missing lines Patch % Lines
src/node_contextify.cc 80.30% 4 Missing and 9 partials ⚠️
src/node_contextify.h 70.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65582      +/-   ##
==========================================
- Coverage   90.07%   90.06%   -0.01%     
==========================================
  Files         751      751              
  Lines      254875   255019     +144     
  Branches    48115    48140      +25     
==========================================
+ Hits       229586   229694     +108     
- Misses      16467    16505      +38     
+ Partials     8822     8820       -2     
Files with missing lines Coverage Δ
lib/vm.js 99.33% <100.00%> (+0.05%) ⬆️
src/node_contextify.h 77.77% <70.00%> (-4.58%) ⬇️
src/node_contextify.cc 81.80% <80.30%> (+0.07%) ⬆️

... and 48 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proposal for shared microtask queues

4 participants