-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
vmIssues and PRs related to the vm subsystem.Issues and PRs related to the vm subsystem.
Description
Version
v17.2.0
Platform
Darwin tidyzq 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:47 PDT 2021; root:xnu-7195.101.2~1/RELEASE_X86_64 x86_64
Subsystem
No response
What steps will reproduce the bug?
const vm = require('vm')
vm.runInNewContext(`
Object.defineProperty(globalThis, 'foo', {
get: () => undefined,
set(v) {
console.log('setter', this === globalThis, this instanceof Object)
}
})
globalThis.foo = 1
`, { console })How often does it reproduce? Is there a required condition?
always reproduce.
What is the expected behavior?
We expect the above code to output:
setter true true
What do you see instead?
node v17.2.0 got the following output:
setter false false
setter true true
Additional information
Only reproduced if a setter is added to globalThis in vm. Adding setter on plain object or run outside vm got the expected output.
Reproduced in node v10.24.1, v16.5.0, v17.2.0, both in repl mode and execution mode.
Not sure about version lower than v10.
Metadata
Metadata
Assignees
Labels
vmIssues and PRs related to the vm subsystem.Issues and PRs related to the vm subsystem.