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
Avoid fancy stack traces size computation #14930
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52942/ |
This will end up with the actual number of frames not exactly matching the user-set Error.stackTraceLimit. However, Error.stackTraceLimit is usually set to generic numbers (10, 100, 1000, Infinity), and it does not matter if it's not _really_ X but a bit less or more. (How long before we get a bug report "Hey, I use Error.stackTraceLimit=1562 but it's only giving me 1543 frames!"?)
ccfb12e
to
c1d94e5
Compare
// is slow (this is why Error.stackTraceLimit does not default to Infinity!). | ||
// Increase it if needed. | ||
const MIN_STACK_TRACE_LIMIT = 50; | ||
Error.stackTraceLimit = Math.max( |
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 (
Error.stackTraceLimit < MIN_STACK_TRACE_LIMIT &&
Error.stackTraceLimit > 10
) {
Error.stackTraceLimit = MIN_STACK_TRACE_LIMIT;
}
Would this be better?
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 only skipped the 0 case. If Error.stackTraceLimit
is a low number, we would otherwise often make it 0 by deleting our own frames (and 0 is worse then "a few more than expected", when you still want something).
This will end up with the actual number of frames not exactly matching the user-set Error.stackTraceLimit. However, Error.stackTraceLimit is usually set to generic numbers (10, 100, 1000, Infinity), and it does not matter if it's not really X but a bit less or more.
(How long before we get a bug report "Hey, I use Error.stackTraceLimit=1562 but it's only giving me 1543 frames!"?)