Skip to content

replay: trimming network responses results block main thread #9426

Closed
@JonasBa

Description

@JonasBa

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.

CleanShot 2023-11-01 at 09 24 10@2x

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: reactIssues related to the Sentry React SDKPackage: replayIssues related to the Sentry Replay SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions