Skip to content

vm: support shared microtask queues - #65582

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

vm: support shared microtask queues#65582
kairosci wants to merge 1 commit 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 related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Aug 27, 2026
Comment thread doc/api/vm.md
* `microtaskQueue` {vm.MicrotaskQueue} A microtask queue created with
[`new vm.MicrotaskQueue()`][] or [`vm.createMicrotaskQueue()`][]. If
specified, microtasks scheduled inside this context will be placed on this
queue, allowing multiple contexts to share the same microtask queue.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could make this an alternative value for microtaskMode, but if not, you should definitely document how these options interact

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 related to general changes in the lib or src directory. 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

3 participants