Skip to content

Commit 5761d04

Browse files
billyvgclaude
andcommitted
fix(replay): Improve error messages when compression worker fails to load
Previously, when the compression worker failed to load (e.g., due to CSP restrictions, network issues), Sentry captured a generic ErrorEvent with almost no useful information ("Event: Event `Event` (type=error)"). This change wraps worker errors in descriptive Error objects that explain what failed and common causes, making debugging significantly easier. Fixes JAVASCRIPT-337J Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e43243e commit 5761d04

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/replay-internal/src/eventBuffer/WorkerHandler.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export class WorkerHandler {
3333
if ((data as WorkerResponse).success) {
3434
resolve();
3535
} else {
36-
reject();
36+
DEBUG_BUILD && debug.warn('Received worker message w/ unsuccessful status', data);
37+
reject(new Error('Received worker message w/ unsuccessful status'));
3738
}
3839
},
3940
{ once: true },
@@ -42,7 +43,12 @@ export class WorkerHandler {
4243
this._worker.addEventListener(
4344
'error',
4445
error => {
45-
reject(error);
46+
DEBUG_BUILD && debug.warn('Failed to load Replay compression worker', error);
47+
reject(
48+
new Error(
49+
`Failed to load Replay compression worker: ${error instanceof ErrorEvent && error.message ? error.message : 'Unknown error. This can happen due to CSP policy restrictions, network issues, or the worker script failing to load.'}`,
50+
),
51+
);
4652
},
4753
{ once: true },
4854
);

0 commit comments

Comments
 (0)