fix(replay): Suppress Worker destroyed error on session expiry - #23409
fix(replay): Suppress Worker destroyed error on session expiry#23409sentry[bot] wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 726af61. Configure here.
| // expected behaviour and not worth reporting to Sentry. | ||
| if (error instanceof WorkerDestroyedError) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
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)
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 726af61. Configure here.
size-limit report 📦
|


The "Error: Worker destroyed" was being reported as a Sentry issue when the
@sentry/replaysession expired. This error occurred because theWorkerHandler'sdestroy()method rejected all pending promises with a genericError('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
WorkerDestroyedErrortype. TheWorkerHandlernow rejects pending promises with this custom error when it's intentionally destroyed. TheEventBufferProxy's_switchToCompressionWorkermethod is updated to specifically catch and silently ignoreWorkerDestroyedErrorinstances. 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:
yarn lint) & (yarn test).Closes #issue_link_here
Fixes JAVASCRIPT-3BE3