-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(core): Avoid crash when Function.prototype is frozen #7899
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
Conversation
const context = getOriginalFunction(this) || this; | ||
return originalFunctionToString.apply(context, args); | ||
}; | ||
try { |
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.
Could you add a comment here for why this try-catch exists? For future reference :) Would also be nice to have an example when/why this may be frozen.
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.
for example:
pwsh> node --frozen-intrinsics
(node:26089) ExperimentalWarning: The --frozen-intrinsics flag is experimental
(Use `node --trace-warnings ...` to show where the warning was created)
Welcome to Node.js v19.9.0.
Type ".help" for more information.
> 'use strict'; Function.prototype.toString = function () { return '' }
Uncaught:
TypeError <Object <Object <[Object: null prototype] {}>>>: Cannot assign to read only property 'toString' of object 'function () { [native code] }'
at Function.setter (node:internal/freeze_intrinsics:499:17)
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, that's perfect!
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 for the PR!
Co-authored-by: Francesco Novy <[email protected]>
Hi @Jack-Works , this has been released in v7.50.0! |
Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint
) & (yarn test
).