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: Works correctly with --frozen-intrinsics
#15626
Conversation
liuxingbaoyu
commented
May 13, 2023
•
edited by gitpod-io
bot
edited by gitpod-io
bot
Q | A |
---|---|
Fixed Issues? | Fixes #15625 |
Patch: Bug Fix? | √ |
Major: Breaking Change? | |
Minor: New Feature? | |
Tests Added + Pass? | √ |
Documentation PR Link | |
Any Dependency Changes? | |
License | MIT |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/54577/ |
96fed85
to
96ebec3
Compare
if (desc === undefined) { | ||
return Object.isExtensible(Error); | ||
} | ||
|
||
return Object.prototype.hasOwnProperty.call(desc, "writable") | ||
? desc.writable | ||
: desc.set !== 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.
if (desc === undefined) { | |
return Object.isExtensible(Error); | |
} | |
return Object.prototype.hasOwnProperty.call(desc, "writable") | |
? desc.writable | |
: desc.set !== undefined; | |
return desc && Object.prototype.hasOwnProperty.call(desc, "writable") && desc.writable; |
Do you think this would be enough? Since stackTraceLimit
is only supported by V8, and:
- if the property doesn't exist, there is no reason to set it because we are in a different engine
- in V8 it's a data property, not a setter
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.
in V8 it's a data property, not a setter
Is it possible for the user to set it to have no setter
?
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.
Yes, but it disables .stack
generation:
➜ node
Welcome to Node.js v20.0.0.
Type ".help" for more information.
> Error.stackTraceLimit = 2
2
> new Error().stack
'Error\n at REPL8:1:1\n at Script.runInThisContext (node:vm:122:12)'
> let limit = 3;
undefined
> Object.defineProperty(Error, "stackTraceLimit", { get: () => limit, set: v => limit = v })
[Function: Error] { stackTraceLimit: [Getter/Setter] }
> Error.stackTraceLimit
3
> new Error().stack
undefined
>
@nicolo-ribaudo Thanks! Yes I'm doing both locally. :) |
7f97dc1
to
bfaa030
Compare
@@ -283,4 +281,28 @@ describe("@babel/core errors", function () { | |||
at ... internal jest frames ..." | |||
`); | |||
}); | |||
|
|||
itGte("12.0.0")( |
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.
I would love to see a PR using itGte
in more places :)