Avoid fancy stack traces size computation#14930
Merged
nicolo-ribaudo merged 2 commits intobabel:mainfrom Sep 14, 2022
Merged
Conversation
1 task
Collaborator
|
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( |
Member
There was a problem hiding this comment.
if (
Error.stackTraceLimit < MIN_STACK_TRACE_LIMIT &&
Error.stackTraceLimit > 10
) {
Error.stackTraceLimit = MIN_STACK_TRACE_LIMIT;
}Would this be better?
Member
Author
There was a problem hiding this comment.
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).
liuxingbaoyu
approved these changes
Sep 14, 2022
JLHwung
approved these changes
Sep 14, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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!"?)