fix(session-replay): prevent blob worker errors from surfacing as uncaught#1561
Open
lewgordon-amplitude wants to merge 2 commits intomainfrom
Open
fix(session-replay): prevent blob worker errors from surfacing as uncaught#1561lewgordon-amplitude wants to merge 2 commits intomainfrom
lewgordon-amplitude wants to merge 2 commits intomainfrom
Conversation
…aught When new Worker(blobUrl) fails (e.g. Firefox ETP, private browsing), the onerror handler correctly falls back to sync compression but was not calling e.preventDefault(). Per the Worker spec this causes the ErrorEvent to re-fire on window.onerror, making a graceful degradation appear as an unhandled crash in the console and error monitoring. Fixes SR-2657 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
Author
|
bugbot run |
Adds a test that properly verifies e.preventDefault() is called when the blob worker fires an error, using a MockWorker with an onerror setter to capture and invoke the handler with a real mock ErrorEvent. The existing test.each error case was passing incidentally — the TypeError from calling preventDefault on a plain object was silently swallowed by addCompressedEvent's DataCloneError try/catch. 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
When new Worker(blobUrl) fails (e.g. Firefox ETP, private browsing), the onerror handler correctly falls back to sync compression but was not calling e.preventDefault(). Per the Worker spec this causes the ErrorEvent to re-fire on window.onerror, making a graceful degradation appear as an unhandled crash in the console and error monitoring. This is related to a sentry error we're seeing on Amplitude: https://amplitude.sentry.io/explore/releases/2b6289da0df5804a5c2ae4d63fdfb90d8876744e/?project=78869
Checklist
Note
Low Risk
Low risk: a small change to web worker error handling plus a targeted unit test; behavior remains a graceful fallback to non-worker compression.
Overview
Fixes session replay web-worker compression fallback by calling
preventDefault()inEventCompressor’sworker.onerrorhandler, preventing worker errors from bubbling towindow.onerroras uncaught.Adds a unit test to assert
preventDefault()is invoked and that the existing fallback behavior still terminates the worker and clearseventCompressor.worker.Written by Cursor Bugbot for commit a95307d. This will update automatically on new commits. Configure here.