Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/react
SDK Version
7.75.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup
No response
Steps to Reproduce
Set up env using replay, enable request body logging, and fetch a response exceeding max body length.
I did a very surface investigation of this, but the issue comes from the fact that replay defines max response body size as 150kB, trims any responses that exceed it, and rebuilds the JSON to again be valid. This seems to all be done synchronously on the client side. This means that the parser rebuilding the JSON will run 150k iterations as it iterates over each char and maintains the matching bracket stack, which is probably enough to cause jank on its own, but I suspect a large part of why this is so slow is because _evaluateJsonPos runs a regexp on each char.
We should look into doing this more efficiently by either workerizing it or reconstructing the JSON on the server.
Expected Result
Replay should not cause jank
Actual Result
Jank