Skip to content

Returning error in prepareStackTrace exceeds maximum callstack size #58195

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

Open
SamVerschueren opened this issue May 6, 2025 · 0 comments
Open
Labels
util Issues and PRs related to the built-in util module.

Comments

@SamVerschueren
Copy link
Contributor

Version

22.15.0

Platform

Darwin Sams-MacBook-Pro-2.local 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041 arm64

Subsystem

No response

What steps will reproduce the bug?

Since this PR #56573 the following code causes a Maximum call stack size exceeded error

Error.prepareStackTrace = (error) => error;

console.log(new Error('foo').stack);
//=> 💥 Maximum call stack size exceeded

It basically happens if error.stack points to the error itself

const err = new Error('foo');
err.stack = err;

console.log(err);

How often does it reproduce? Is there a required condition?

No

What is the expected behavior? Why is that the expected behavior?

Before that PR, it just printed the error

Error.prepareStackTrace = (error) => error;

console.log(new Error('unicorn').stack);
//=> [Error foo]
const err = new Error('foo');
err.stack = err;

console.log(err);
//=> [Error foo]

What do you see instead?

💥 Maximum call stack size exceeded

Additional information

No response

@daeyeon daeyeon added the util Issues and PRs related to the built-in util module. label May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
util Issues and PRs related to the built-in util module.
Projects
None yet
Development

No branches or pull requests

2 participants