-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vm: Function declarations should use [[Define]] instead of [[Set]] on the global object #31808
Comments
Well, |
This is fixed by 30709 |
#30709 should include tests for this. |
Fixes nodejs#855 Fixes nodejs#31658 Fixes nodejs#31808
@Mesteery Does this test pass?
If not, then this issue should remain open. |
Surprisingly, this is still an issue. Tested v22.7.0 and v20.17.0. I hope it is OK to cc @targos and @legendecas as people working in the area recently. Because of this issue jsdom has lots of global properties which are currently data properties, and it is too scary for us to upgrade them to getters + setters (matching specs) because suddenly a bunch of scripts running in the jsdom context might start breaking. |
I don't know if it really is a Node.js bug. V8 calls the |
Hmm, OK. Do you know if there's an upstream tracking bug on V8 then? I can try filing one but I think you know more about the relevant code so would be able to file a better one... |
Here's a stack trace:
We see that This seems to be a known limitation: node/deps/v8/src/objects/objects.h Lines 108 to 116 in 7fea010
Comment added in v8/v8@4ee68d8 I don't know if there's an open V8 bug about this. /cc @joyeecheung |
Yes I noticed that issue when implementing class fields and avoided that weird behavior with a separate path for class fields. But ordinary Object.defineProperty() still has that old behavior AFAICT. I never got around to investigate whether the old behavior could be broken. |
Here is the bug I opened a while back after I discovered that behavior: https://issues.chromium.org/u/2/issues/42202495, |
BTW for interceptor-less contexts, there is also #54394 though I am not sure if that meets all the requirements of jsdom (if you care about the constructor of the global object, maybe it doesn't?) |
Based on some initial testing I think However, since it won't be supported in all active LTS versions until ~May 2026, it isn't very helpful for us now :( |
FWIW the next v20.x version will include |
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
The functions get defined using
[[DefineOwnProperty]]
as specified in ECMA‑262 § 8.1.1.4.18CreateGlobalFunctionBinding
.Expected log output
What do you see instead?
Additional information
Discovered in: jsdom/jsdom#2835 (comment)
See also
The text was updated successfully, but these errors were encountered: