Skip to content

vm: allow global proxy reuse across contexts - #65477

Open
koal44 wants to merge 1 commit into
nodejs:mainfrom
koal44:vm-global-proxy-reuse
Open

vm: allow global proxy reuse across contexts#65477
koal44 wants to merge 1 commit into
nodejs:mainfrom
koal44:vm-global-proxy-reuse

Conversation

@koal44

@koal44 koal44 commented Aug 22, 2026

Copy link
Copy Markdown

Cross-document navigation in a browsing context creates a new Window and realm while preserving the identity of its WindowProxy/globalThis. Modeling this behavior with node:vm is currently not possible, as discussed in #855 and #31807.

This PR adds a reuseGlobalProxy option to vm.createContext(). When supplied a global proxy produced with vm.constants.DONT_CONTEXTIFY, Node.js detaches it from the old context and attaches it to a new one.

The implementation was inspired by Chromium’s approach: detaching the old context, then passing the preserved global proxy into the replacement context.

Conceptually:

old_context->DetachGlobal();
new_context = Context::New(/* ... */, old_global_proxy);

Signed-off-by: koal44 <random.var.ny@gmail.com>
@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 22, 2026
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.

2 participants