fix(replay): Ensure we normalize scope breadcrumbs to max. depth to avoid circular ref#7915
Merged
fix(replay): Ensure we normalize scope breadcrumbs to max. depth to avoid circular ref#7915
Conversation
billyvg
reviewed
Apr 20, 2023
Contributor
size-limit report 📦
|
c6a5370 to
21da1b5
Compare
lforst
approved these changes
Apr 20, 2023
| timestamp: (breadcrumb.timestamp || 0) * 1000, | ||
| data: { | ||
| tag: 'breadcrumb', | ||
| payload: normalize(breadcrumb), |
Contributor
There was a problem hiding this comment.
We could use the normalizeDepth client option and set the max breadth to smth like 1_000 - which I find a sane number that will prevent an insane amount of data from being generated.
Member
Author
There was a problem hiding this comment.
Hmm, I think we may want to have a dedicated setting for the depth here eventually, as we may not need as much depth here as in other places, for example. But a good point, will think about it. Will also add 1_000 as max properties, sounds like a good additional check!
Lms24
approved these changes
Apr 20, 2023
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
After some in-depth debugging, I figured out that the replay may lock up if we do not normalize the scope breadcrumbs to a given depth.
This seems to fix the provided reproduction for me, and seems like a reasonable change overall.
10 is more or less a random value, but seems reasonable for me for this case?
it gets slower and slower with an increasing value there, becoming basically unusable around ~18-20.
I did some further digging, and the problem is that around a normalization of 20, it becomes crazy large:
results in a 60MB string 🤯
This is a simple first step to ensure we normalize all breadcrumbs to a max. depth. This applies to scope & dom breadcrumbs from Sentry itself.
This is not really a fix per se, as it could still be massive in shallow size. But it should help generally, and is perf-free (or even positive), as we are already walking this in
normalizeanyhow.Ref https://github.com/getsentry/team-replay/issues/67