fix(session-replay-browser): reduce snapshot size and handle 413s#1685
Open
lewgordon-amplitude wants to merge 5 commits intomainfrom
Open
fix(session-replay-browser): reduce snapshot size and handle 413s#1685lewgordon-amplitude wants to merge 5 commits intomainfrom
lewgordon-amplitude wants to merge 5 commits intomainfrom
Conversation
…p oversized events at capture - Add MAX_SINGLE_EVENT_SIZE guard in EventCompressor to silently drop events that exceed the server's size limit before sending - Bisect-retry logic in track-destination: on a WAF 413 (body contains "Payload exceeds"), split the batch in half and retry each half independently; bottom out at single events to avoid infinite loops - Add MAX_SINGLE_EVENT_SIZE constant (9 MB) - Add e2e tests covering oversized capture-time drop and 413 retry - Move e2e test server to port 5174 to isolate worktree from main-branch Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Session Replay Browser E2E ResultsDetails
|
Collaborator
Author
|
bugbot run |
… 413 useRetry inconsistency - Enable all rrweb slimDOMOptions by default (scripts, comments, all head meta/favicon/whitespace tags) — none affect replay fidelity - Remove omitElementTags from public config; stripping is now unconditional - Fix worker sendWithRetry: only bisect on 413 when useRetry=true, matching main-thread behavior for flush(false) calls Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit f4b94d0. Configure here.
…limDOM is always enabled Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…in oversized-event warnings Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
Reduce snapshot payload size
slimDOMOptionsby default: scripts, comments, favicons, head whitespace, and all head meta tags (description/keywords, social, robots, http-equiv, authorship, verification) are now stripped from snapshots. None of these affect replay fidelity.omitElementTagsconfig option (was only wiring upscriptandcomment; now all slim-DOM stripping is unconditional)WAF 413 bisect-retry
"Payload exceeds"), split the event batch in half and retry each half independently; recurse until batches reach a single event, then stop and warnCapture-time drop for oversized single events
MAX_SINGLE_EVENT_SIZEconstant (9 MB)EventCompressor.addCompressedEventToManagerdrops any serialized event exceeding the limit before it's queued — avoids a wasted network round trip for snapshots that would fail the server's ~10 MB limit anywayTests
size-limits.spec.ts): oversized event not delivered, SDK recovers after drop, WAF 413 triggers bisect-retry, app-layer 413 doesn't loopChecklist
omitElementTagsremoved from public config (was undocumented/unused in practice)Note
Medium Risk
Medium risk because it changes replay payload shaping and delivery retry behavior (including dropping events and splitting batches on 413), which could affect data completeness and network/load patterns.
Overview
Improves session replay reliability/size limits by dropping oversized single rrweb events (new
MAX_SINGLE_EVENT_SIZEguard) and filtering any previously-stored oversized events before send.Adds 413 Payload Too Large handling: when a 413 matches the WAF signature (
"Payload exceeds"), the SDK bisects the event batch and retries each half until it bottoms out at a single event (which is then dropped with a warning); this behavior works in both main-thread and worker send paths.Reduces snapshot payload size by enabling rrweb
slimDOMOptionsdefaults (scripts/comments + head/favicon/meta trimming) and removes theomitElementTagsoption.Expands unit/e2e coverage for oversized-event dropping and 413 behaviors (including “no infinite loop” and post-413 recovery), adds a dedicated
size-limits.spec.ts, and moves the Playwright e2e server to port5174.Reviewed by Cursor Bugbot for commit f4b94d0. Bugbot is set up for automated code reviews on this repo. Configure here.