Commit 72a5e4f
authored
fix(replay): Set text/javascript MIME type on compression worker Blob (#22377)
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.
```ts
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.1 parent d092fd4 commit 72a5e4f
3 files changed
Lines changed: 36 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
8 | 14 | | |
9 | 15 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
0 commit comments