Skip to content
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

Merged
merged 5 commits into from Jun 13, 2023

Conversation

liuxingbaoyu
Copy link
Member

@liuxingbaoyu liuxingbaoyu commented May 13, 2023

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

@liuxingbaoyu liuxingbaoyu added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: core labels May 13, 2023
@babel-bot
Copy link
Collaborator

babel-bot commented May 13, 2023

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/54577/

liuxingbaoyu and others added 3 commits May 29, 2023 22:37
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Comment on lines 76 to 82
if (desc === undefined) {
return Object.isExtensible(Error);
}

return Object.prototype.hasOwnProperty.call(desc, "writable")
? desc.writable
: desc.set !== undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Member Author

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?

Copy link
Member

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
> 

@liuxingbaoyu
Copy link
Member Author

@nicolo-ribaudo Thanks! Yes I'm doing both locally. :)

@liuxingbaoyu liuxingbaoyu added the PR: Needs Review A pull request awaiting more approvals label Jun 11, 2023
@@ -283,4 +281,28 @@ describe("@babel/core errors", function () {
at ... internal jest frames ..."
`);
});

itGte("12.0.0")(
Copy link
Member

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 :)

@nicolo-ribaudo nicolo-ribaudo merged commit 5fed5af into babel:main Jun 13, 2023
54 checks passed
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 13, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: core PR: Bug Fix 🐛 A type of pull request used for our changelog categories PR: Needs Review A pull request awaiting more approvals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Cannot assign to read only property 'stackTraceLimit'
4 participants