replay: trimming network responses results block main thread #9426
Labels
Package: react
Issues related to the Sentry React SDK
Package: replay
Issues related to the Sentry Replay SDK
Type: Bug
Is there an existing issue for this?
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
The text was updated successfully, but these errors were encountered: