-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix: Use static Reflect methods in nodeGlobalThis proxy #17696
Conversation
One thing worth mentioning is that this issue does not occur when loading the module in-directly via eg. this works just fine, even without this fix import { createRequire } from "https://deno.land/std@0.177.0/node/module.ts";
const require = createRequire(import.meta.url);
const prettier = require("./prettier");
prettier.format('', {filename: '1.js'}); |
console.log(setTimeout); | ||
delete nodeGlobalThis["setTimeout"]; | ||
console.log(nodeGlobalThis["setTimeout"]); // should be undefined | ||
console.log(globalThis["setTimeout"]); // should be undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On main these both go to undefined
. I'm not entirely sure if this one should, but that's the current behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This looks good other than the behaviour change in delete.
Good catch, thanks! Updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
For some reason, this block was getting confused, and when missing property (eg.
RegExp
) was asked for,globalThis[prop]
pointed to the same proxied object, which then recursed infinitely.One solution was to just use
target[prop]
instead, however for the sake of completeness, I changed all methods to useReflect
instead, asownKeys
,defineProperty
andgetOwnPropertyDescriptor
already did that.I cannot come up with an explicit test-case (didnt invest much time into it yet), but so far all current tests are passing and linked issue is fixed when trying repro locally.
Fixes #17678