Skip to content

fix(session-replay-browser): prevent worker script load failure from blob URLs#1522

Merged
lewgordon-amplitude merged 1 commit into
mainfrom
SR-2446
Feb 17, 2026
Merged

fix(session-replay-browser): prevent worker script load failure from blob URLs#1522
lewgordon-amplitude merged 1 commit into
mainfrom
SR-2446

Conversation

@lewgordon-amplitude
Copy link
Copy Markdown
Collaborator

@lewgordon-amplitude lewgordon-amplitude commented Feb 5, 2026

Summary

Disabled sourcemaps in worker bundle to prevent importScripts failures when loading worker from blob URLs. Added error handling to gracefully fall back to non-worker compression if worker creation or execution fails.

The worker build was generating sourcemap references that couldn't be resolved in blob URL contexts, causing NetworkError when the worker tried to load them.

Not sure of the best way to repro this, but hopefully we can follow the initial sentry issue.

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?:

Note

Low Risk
Build config and defensive error-handling changes with a clear fallback path; primary risk is reduced worker debugging due to disabled sourcemaps.

Overview
Prevents session replay compression web workers from failing when loaded from blob URLs by disabling sourcemaps for the inlined worker bundle generation.

Hardens EventCompressor web worker usage by wrapping worker creation in try/catch and, on worker runtime error, terminating the worker and falling back to in-thread compression; adds a unit test covering Worker constructor failure fallback.

Written by Cursor Bugbot for commit ac98235. This will update automatically on new commits. Configure here.

@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Feb 5, 2026

Handle web worker failures in EventCompressor.constructor and build session-replay-browser worker without sourcemaps to address blob URL load errors

Wrap worker initialization with Blob/URL.createObjectURL and try/catch in packages/session-replay-browser/src/events/event-compressor.ts; terminate and unset this.worker on onerror to fall back to non-worker compression; disable sourcemap in packages/session-replay-browser/rollup.config.js.

🖇️ Linked Issues

Resolves blob-based worker load errors reported in SR-2446 by adjusting worker creation and disabling sourcemaps in the worker build.

📍Where to Start

Start with the EventCompressor.constructor initialization and error handling in packages/session-replay-browser/src/events/event-compressor.ts.


Macroscope summarized 490bc8e.

@lewgordon-amplitude lewgordon-amplitude marked this pull request as ready for review February 5, 2026 14:09
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Feb 5, 2026

Handle web worker initialization failures in EventCompressor and remove sourcemaps in worker bundle to mitigate blob URL importScripts load errors in rollup.config.js

Wrap EventCompressor worker creation in try/catch, create a Blob and Blob URL explicitly, terminate and clear the worker on onerror, and disable worker sourcemaps (sourcemap: false) in the web worker build.

🖇️ Linked Issues

Addresses Sentry-reported blob URL worker load failures tracked in SR-2446.

📍Where to Start

Start with the EventCompressor constructor in event-compressor.ts.


Macroscope summarized ac98235.

…blob URLs

Disabled sourcemaps in worker bundle to prevent importScripts failures when
loading worker from blob URLs. Added error handling to gracefully fall back
to non-worker compression if worker creation or execution fails.

The worker build was generating sourcemap references that couldn't be resolved
in blob URL contexts, causing NetworkError when the worker tried to load them.

Co-authored-by: Cursor <cursoragent@cursor.com>
@lewgordon-amplitude lewgordon-amplitude requested review from a team and jxiwang and removed request for jxiwang February 10, 2026 16:06
@lewgordon-amplitude lewgordon-amplitude merged commit decccae into main Feb 17, 2026
11 checks passed
@lewgordon-amplitude lewgordon-amplitude deleted the SR-2446 branch February 17, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants