Skip to content

Commit bc25ab9

Browse files
billyvgclaudeandreiborza
authored
fix(replay): Improve error messages when compression worker fails to load (#19008)
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> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Andrei <168741329+andreiborza@users.noreply.github.com> Co-authored-by: Andrei Borza <andrei.borza@sentry.io>
1 parent 57a048d commit bc25ab9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.size-limit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ module.exports = [
8989
path: 'packages/browser/build/npm/esm/prod/index.js',
9090
import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'feedbackIntegration'),
9191
gzip: true,
92-
limit: '98 KB',
92+
limit: '99 KB',
9393
},
9494
{
9595
name: '@sentry/browser (incl. Feedback)',
@@ -208,7 +208,7 @@ module.exports = [
208208
name: 'CDN Bundle (incl. Tracing, Replay)',
209209
path: createCDNPath('bundle.tracing.replay.min.js'),
210210
gzip: true,
211-
limit: '80 KB',
211+
limit: '81 KB',
212212
},
213213
{
214214
name: 'CDN Bundle (incl. Tracing, Replay, Logs, Metrics)',

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 with unsuccessful status', data);
37+
reject(new Error('Received worker message with 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)