Repository navigation
fix(vm): preserve DONT_CONTEXTIFY global receiver identity - #176
Conversation
Port the real-global implementation from oven-sh#34623, originally by robobun. Remove the wrapper that separated top-level this from the returned context, and preserve parsing-context and code-generation behavior. Cover private-field branding, strict/sloppy receivers, indirect eval, Function, and compilation-cache reuse across distinct contexts.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5dfb1b466b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (name !== undefined) validateString(name, "options.contextName"); | ||
| if (origin !== undefined) validateString(origin, "options.contextOrigin"); | ||
| let codeGeneration; | ||
| const contextCodeGeneration = options.contextCodeGeneration; |
There was a problem hiding this comment.
Preserve Node's repeated context-option getter reads
When options uses accessors or a Proxy, caching contextCodeGeneration here—and microtaskMode above—changes observable behavior. Node 24's getContextOptions rereads contextCodeGeneration for the presence check, validation, and destructuring; for example, a getter returning {}, {}, then { strings: false } makes Node disable eval, whereas this implementation configures the context from the first object and permits it. Read and validate these properties in Node's order rather than memoizing them.
AGENTS.md reference: AGENTS.md:L187-L191
Useful? React with 👍 / 👎.
What does this PR do?
Ports the DONT_CONTEXTIFY global fix from oven-sh#34623. Creating a VM context in this mode currently returns a wrapper, while top-level
thisuses the realm's global proxy. This breaks private-field branding used by jsdom: a field stamped on the returned context cannot be read throughwindow.Return the existing global proxy without attaching a sandbox, remove the wrapper, preserve that global during script evaluation, and accept it as a
compileFunctionparsing context. Reuse it inrunInNewContextwhile retaining code-generation options. Ordinary contextified globals keep their sandbox behavior. The private compilation cache and its keys are unchanged; scripts continue linking against the target global on each evaluation.Adds option-validation and forced private-cache hit tests, plus Node-oracle regression coverage for strict/sloppy scripts, indirect eval, Function, compileFunction, private fields, and shared scripts across contexts.
Related upstream work: oven-sh#34623, oven-sh#38316, oven-sh#45284, and oven-sh#45102. Thanks robobun for the original implementation.
How did you verify your code works?
f2405c382d43b89d91a2e7c90d9c5f53505a1e71also reproduces the original failure.extensions/team-reports/src/render/theme.test.tschanges from 6 failures to 6 passes on the same source checkout.