Skip to content

fix(replay): Suppress Worker destroyed error on session expiry - #23409

Open
sentry[bot] wants to merge 1 commit into
developfrom
seer/fix/replay-worker-destroyed-error
Open

fix(replay): Suppress Worker destroyed error on session expiry#23409
sentry[bot] wants to merge 1 commit into
developfrom
seer/fix/replay-worker-destroyed-error

Conversation

@sentry

@sentry sentry Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

The "Error: Worker destroyed" was being reported as a Sentry issue when the @sentry/replay session expired. This error occurred because the WorkerHandler's destroy() method rejected all pending promises with a generic Error('Worker destroyed')) when the worker was intentionally terminated during session teardown.

This was a false positive, as the worker destruction is an expected part of the replay session's lifecycle, not an actual failure.

This fix introduces a specific WorkerDestroyedError type. The WorkerHandler now rejects pending promises with this custom error when it's intentionally destroyed. The EventBufferProxy's _switchToCompressionWorker method is updated to specifically catch and silently ignore WorkerDestroyedError instances. This ensures that only unexpected worker-related errors are captured and reported to Sentry, while expected teardown events are suppressed.

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).
  • Link an issue if there is one related to your pull request. If no issue is linked, one will be auto-generated and linked.

Closes #issue_link_here

Fixes JAVASCRIPT-3BE3

@sentry
sentry Bot requested a review from a team as a code owner August 13, 2026 15:00
@sentry
sentry Bot requested review from logaretm and msonnb and removed request for a team August 13, 2026 15:00

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 726af61. Configure here.

// expected behaviour and not worth reporting to Sentry.
if (error instanceof WorkerDestroyedError) {
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fix PR missing regression tests

Medium Severity

This is a fix PR, but the diff adds no unit, integration, or E2E test covering the regression. Per the Testing Conventions in the PR review guidelines (flagged because it was mentioned in the rules file), a fix should include a test that fails without the change and passes with it — for example, asserting that destroying the worker during _switchToCompressionWorker is silently ignored and does not go through debug.exception.

Additional Locations (2)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 726af61. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 30.3 kB - -
@sentry/browser - with treeshaking flags 28.47 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.81 kB - -
@sentry/browser (incl. Tracing) 48.58 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.59 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.46 kB - -
@sentry/browser (incl. Tracing, Replay) 88 kB +0.03% +22 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.38 kB +0.03% +21 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 92.72 kB +0.03% +21 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 105.43 kB +0.04% +33 B 🔺
@sentry/browser (incl. Feedback) 47.65 kB - -
@sentry/browser (incl. sendFeedback) 35.13 kB - -
@sentry/browser (incl. FeedbackAsync) 40.28 kB - -
@sentry/browser (incl. Metrics) 31.24 kB - -
@sentry/browser (incl. Logs) 31.52 kB - -
@sentry/browser (incl. Metrics & Logs) 32.15 kB - -
@sentry/react 32.09 kB - -
@sentry/react (incl. Tracing) 50.77 kB - -
@sentry/vue 35.34 kB - -
@sentry/vue (incl. Tracing) 50.54 kB - -
@sentry/svelte 30.33 kB - -
CDN Bundle 31.61 kB - -
CDN Bundle (incl. Tracing) 48.89 kB - -
CDN Bundle (incl. Logs, Metrics) 33.8 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.82 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.32 kB +0.03% +19 B 🔺
CDN Bundle (incl. Tracing, Replay) 86.49 kB +0.02% +15 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.32 kB +0.02% +16 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 92.2 kB +0.03% +19 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.13 kB +0.02% +13 B 🔺
CDN Bundle - uncompressed 93.84 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.74 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.43 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.14 kB +0.03% +66 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.07 kB +0.03% +66 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.74 kB +0.03% +66 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.77 kB +0.03% +66 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.43 kB +0.03% +66 B 🔺
@sentry/nextjs (client) 53.29 kB - -
@sentry/sveltekit (client) 49 kB - -
@sentry/core/server 65.37 kB - -
@sentry/core/browser 51.7 kB - -
@sentry/node 117.14 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 81.44 kB +0.01% +1 B 🔺
@sentry/aws-serverless 90.92 kB - -
@sentry/cloudflare (withSentry) - minified 213.99 kB - -
@sentry/cloudflare (withSentry) 528.92 kB - -

View base workflow run

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.

1 participant