Skip to content

fix(replay): Set text/javascript MIME type on compression worker Blob#22377

Open
billyvg wants to merge 1 commit into
developfrom
bv/fix-replay-worker-safari-mime
Open

fix(replay): Set text/javascript MIME type on compression worker Blob#22377
billyvg wants to merge 1 commit into
developfrom
bv/fix-replay-worker-safari-mime

Conversation

@billyvg

@billyvg billyvg commented Jul 17, 2026

Copy link
Copy Markdown
Member

tbh I can't find a URL that says safari is more prone to not load a worker blob if it doesn't have a MIME type, but seems reasonable to add one.

Slop

getWorkerURL() builds the Replay compression worker from a Blob URL, but the Blob was created without a MIME type, so it defaulted to an empty type. Safari (especially on iOS) validates the MIME type before executing a Blob as a classic Worker and silently rejects a non-JS type — firing a bare error event with no message, which the SDK surfaces as:

Failed to load Replay compression worker: Unknown error. This can happen due to CSP policy restrictions, network issues, or the worker script failing to load.

Blink/Gecko are lenient about the blob MIME type, so this particular failure mode is Safari-specific. Tagging the blob text/javascript is the standard cross-browser fix.

const workerBlob = new Blob([workerString], { type: 'text/javascript' });

This is a handled error — recording already falls back to the uncompressed buffer — so there is no user-facing behavior change beyond the worker actually loading on Safari.

Testing

  • New packages/replay-worker/test/unit/getWorkerURL.test.ts asserts the blob is created with the text/javascript MIME type.
  • oxlint + oxfmt clean; replay-worker suite passes.

Notes

This is the low-risk half of a split. A separate follow-up PR handles the cross-browser (Chrome/Edge/Firefox) occurrences of the same captured error, which come from the worker fetch being aborted during page navigation/teardown rather than from the MIME type. Follow-up to #19008, which introduced the descriptive error message but did not address the load failure itself.

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.75 kB - -
@sentry/browser - with treeshaking flags 26.18 kB - -
@sentry/browser (incl. Tracing) 46.56 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.37 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.36 kB - -
@sentry/browser (incl. Tracing, Replay) 85.84 kB +0.02% +11 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.46 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.55 kB +0.01% +1 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 103.21 kB +0.01% +8 B 🔺
@sentry/browser (incl. Feedback) 44.93 kB - -
@sentry/browser (incl. sendFeedback) 32.55 kB - -
@sentry/browser (incl. FeedbackAsync) 37.69 kB - -
@sentry/browser (incl. Metrics) 28.83 kB - -
@sentry/browser (incl. Logs) 29.05 kB - -
@sentry/browser (incl. Metrics & Logs) 29.76 kB - -
@sentry/react 29.54 kB - -
@sentry/react (incl. Tracing) 48.84 kB - -
@sentry/vue 33.17 kB - -
@sentry/vue (incl. Tracing) 48.51 kB - -
@sentry/svelte 27.78 kB - -
CDN Bundle 30.14 kB - -
CDN Bundle (incl. Tracing) 48.53 kB - -
CDN Bundle (incl. Logs, Metrics) 31.73 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.83 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.99 kB +0.02% +10 B 🔺
CDN Bundle (incl. Tracing, Replay) 86.05 kB +0.02% +10 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.35 kB +0.02% +10 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 91.85 kB +0.01% +9 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 93.12 kB +0.02% +10 B 🔺
CDN Bundle - uncompressed 89.88 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.73 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.59 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.71 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.35 kB +0.02% +25 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.96 kB +0.01% +25 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.93 kB +0.01% +25 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.67 kB +0.01% +25 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 283.62 kB +0.01% +25 B 🔺
@sentry/nextjs (client) 51.36 kB - -
@sentry/sveltekit (client) 46.99 kB - -
@sentry/core/server 78.65 kB - -
@sentry/core/browser 65.08 kB - -
@sentry/node-core 63.21 kB - -
@sentry/node 125.66 kB -0.01% -1 B 🔽
@sentry/node (incl. diagnostics channel injection) 149.25 kB -0.01% -1 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.03 kB - -
@sentry/node/light 51.32 kB - -
@sentry/node - without tracing 74.92 kB +0.01% +1 B 🔺
@sentry/aws-serverless 84.15 kB - -
@sentry/cloudflare (withSentry) - minified 184 kB - -
@sentry/cloudflare (withSentry) 455.41 kB - -

View base workflow run

The compression worker is created from a Blob URL, but the Blob was
constructed without a MIME type, so it defaulted to an empty type. Safari
(especially on iOS) validates the MIME type before executing a Blob as a
classic Worker and silently rejects a non-JS type, firing a bare `error`
event with no message — surfaced by the SDK as "Failed to load Replay
compression worker: Unknown error". Blink/Gecko are lenient here, so this
only manifests on Safari.

Tagging the Blob `text/javascript` lets the worker load across browsers.
@billyvg
billyvg force-pushed the bv/fix-replay-worker-safari-mime branch from 52b463b to 4d2c632 Compare July 17, 2026 21:20
@billyvg billyvg changed the title fix(replay): Set worker Blob MIME type and clarify load-failure errors fix(replay): Set text/javascript MIME type on compression worker Blob Jul 17, 2026
@billyvg

billyvg commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

@sentry review

@billyvg
billyvg marked this pull request as ready for review July 17, 2026 21:30
@billyvg
billyvg requested a review from a team as a code owner July 17, 2026 21:30
@billyvg
billyvg requested review from logaretm and msonnb and removed request for a team July 17, 2026 21:30
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