Skip to content

fix(replay): Improve error messages when compression worker fails to load#19008

Merged
andreiborza merged 6 commits intodevelopfrom
feat-replay-add-error-message-compression-working
Feb 10, 2026
Merged

fix(replay): Improve error messages when compression worker fails to load#19008
andreiborza merged 6 commits intodevelopfrom
feat-replay-add-error-message-compression-working

Conversation

@billyvg
Copy link
Member

@billyvg billyvg commented Jan 27, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 27, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.53 kB - -
@sentry/browser - with treeshaking flags 24.05 kB - -
@sentry/browser (incl. Tracing) 42.36 kB - -
@sentry/browser (incl. Tracing, Profiling) 47.02 kB - -
@sentry/browser (incl. Tracing, Replay) 81.14 kB +0.17% +133 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.77 kB +0.18% +125 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 85.84 kB +0.16% +131 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 98.02 kB +0.12% +117 B 🔺
@sentry/browser (incl. Feedback) 42.27 kB - -
@sentry/browser (incl. sendFeedback) 30.22 kB - -
@sentry/browser (incl. FeedbackAsync) 35.21 kB - -
@sentry/browser (incl. Metrics) 26.71 kB - -
@sentry/browser (incl. Logs) 26.85 kB - -
@sentry/browser (incl. Metrics & Logs) 27.53 kB - -
@sentry/react 27.3 kB - -
@sentry/react (incl. Tracing) 44.68 kB - -
@sentry/vue 29.98 kB - -
@sentry/vue (incl. Tracing) 44.2 kB - -
@sentry/svelte 25.55 kB - -
CDN Bundle 28.08 kB - -
CDN Bundle (incl. Tracing) 43.15 kB - -
CDN Bundle (incl. Logs, Metrics) 28.92 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 43.99 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 67.99 kB +0.2% +131 B 🔺
CDN Bundle (incl. Tracing, Replay) 80.04 kB +0.17% +130 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 80.91 kB +0.18% +142 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 85.46 kB +0.16% +132 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.36 kB +0.16% +131 B 🔺
CDN Bundle - uncompressed 82.12 kB - -
CDN Bundle (incl. Tracing) - uncompressed 127.83 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 84.95 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 130.66 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 208.62 kB +0.14% +281 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.71 kB +0.12% +281 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 247.53 kB +0.12% +281 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.51 kB +0.11% +281 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 260.32 kB +0.11% +281 B 🔺
@sentry/nextjs (client) 47.02 kB - -
@sentry/sveltekit (client) 42.78 kB - -
@sentry/node-core 52.19 kB - -
@sentry/node 166.32 kB - -
@sentry/node - without tracing 93.97 kB - -
@sentry/aws-serverless 109.48 kB +0.01% +1 B 🔺

View base workflow run

@billyvg billyvg marked this pull request as ready for review January 27, 2026 18:43
@billyvg billyvg requested a review from a team as a code owner January 27, 2026 18:43
new Error(
`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.'}`,
),
);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test for improved error message regression fix

Low Severity · Bugbot Rules

This PR improves error messages when the compression worker fails to load, but no tests were added to verify the improved error messages are actually produced. The existing test at EventBufferProxy.test.ts only checks that the fallback buffer is used when the worker fails, not that the new descriptive Error objects are correctly constructed and rejected with the expected messages. Per the review rules: "When reviewing a fix PR, check if the PR includes at least one unit, integration or e2e test that tests the regression this PR fixes."

Additional Locations (1)

Fix in Cursor Fix in Web

'error',
error => {
reject(error);
DEBUG_BUILD && debug.warn('Failed to load Replay compression worker', error);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant debug logging results in duplicate error messages

Low Severity

The new debug.warn calls at lines 36 and 46 are redundant because the caller EventBufferProxy._ensureWorkerIsLoaded() already logs these errors using debug.exception(). Looking at the logger implementation, debug.exception() logs both the message AND the error object to the console. This means when the worker fails to load, the same error appears multiple times in debug output - first as a warning from WorkerHandler, then as error logs from EventBufferProxy. The existing logging in EventBufferProxy provides more useful context (mentioning the fallback behavior), making the new logs unnecessary noise.

Additional Locations (1)

Fix in Cursor Fix in Web

@github-actions
Copy link
Contributor

github-actions bot commented Jan 28, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,475 - 11,850 -28%
GET With Sentry 1,621 19% 2,065 -22%
GET With Sentry (error only) 5,825 69% 7,827 -26%
POST Baseline 1,147 - 1,293 -11%
POST With Sentry 560 49% 643 -13%
POST With Sentry (error only) 1,021 89% 1,166 -12%
MYSQL Baseline 3,183 - 3,564 -11%
MYSQL With Sentry 385 12% 528 -27%
MYSQL With Sentry (error only) 2,578 81% 3,057 -16%

View base workflow run

@billyvg billyvg force-pushed the feat-replay-add-error-message-compression-working branch from 2d55530 to 5db8e19 Compare February 9, 2026 18:30
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

Codecov Results 📊

538 passed | ⏭️ 49 skipped | Total: 587 | Pass Rate: 91.65% | Execution Time: 15m 7s

All tests are passing successfully.


Generated by Codecov Action

billyvg and others added 4 commits February 9, 2026 18:00
…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>
Co-authored-by: Andrei <168741329+andreiborza@users.noreply.github.com>
@billyvg billyvg force-pushed the feat-replay-add-error-message-compression-working branch from 83af4b8 to a442dd3 Compare February 9, 2026 23:00
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'feedbackIntegration'),
gzip: true,
limit: '98 KB',
limit: '99 KB',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundle size increase in browser package flagged

Low Severity

Per the review rules: "Large bundle size increases in browser packages. Sometimes they're unavoidable but flag them anyway." The size limit for @sentry/browser (incl. Tracing, Replay, Feedback) was bumped from 98 KB to 99 KB. The increase comes from the new descriptive error message strings added to WorkerHandler. This is likely unavoidable given the goal of improving error messages, but worth noting.

Fix in Cursor Fix in Web

@andreiborza andreiborza merged commit bc25ab9 into develop Feb 10, 2026
429 of 431 checks passed
@andreiborza andreiborza deleted the feat-replay-add-error-message-compression-working branch February 10, 2026 10:50
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.

3 participants