Skip to content

vm: preserve attributes when redefining built-in globals - #67365

Draft
Anshikakalpana wants to merge 1 commit into
nodejs:mainfrom
Anshikakalpana:vm-define-property-builtin-globals
Draft

Anshikakalpana wants to merge 1 commit into
nodejs:mainfrom
Anshikakalpana:vm-define-property-builtin-globals

Conversation

@Anshikakalpana

Copy link
Copy Markdown
Contributor

PropertyDefinerCallback always defines on the sandbox. Built-in globals such as globalThis exist on the real global but not on the sandbox, so Object.defineProperty(globalThis, 'globalThis', {}) created a fresh property with default attributes (value: undefined, all flags false) instead of preserving the existing ones.

If the property is declared on the global but absent from the sandbox, return Intercepted::kNo so V8 performs the ordinary define on the real global, which preserves unspecified attributes.

Added a regression test to test-vm-property-definer-partial-update.js. It fails without the change and passes with it. test-vm-*, test-repl*, test-global* and test-util-inspect* pass locally.

Fixes: #67351

Signed-off-by: Anshika Jain <anshikajain196872@gmail.com>
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem. labels Nov 9, 2026
@Anshikakalpana
Anshikakalpana marked this pull request as draft November 9, 2026 20:44
@codecov

codecov Bot commented Nov 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.71%. Comparing base (9aa379e) to head (8a60d40).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67365      +/-   ##
==========================================
- Coverage   90.72%   90.71%   -0.01%     
==========================================
  Files         798      798              
  Lines      280015   280020       +5     
  Branches    53858    53856       -2     
==========================================
- Hits       254046   254031      -15     
- Misses      16264    16282      +18     
- Partials     9705     9707       +2     
Files with missing lines Coverage Δ
src/node_contextify.cc 81.74% <100.00%> (+0.12%) ⬆️

... and 23 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++. needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

defineProperty misbehaves with contextified vm global objects

2 participants