fix(service-worker): skip Sentry capture for AbortErrors from update checks#119459
Draft
billyvg wants to merge 2 commits into
Draft
fix(service-worker): skip Sentry capture for AbortErrors from update checks#119459billyvg wants to merge 2 commits into
billyvg wants to merge 2 commits into
Conversation
…checks When `registration.update()` is aborted (e.g. the user navigates away while a service-worker update check is in progress), the browser throws an `AbortError` with the message "Failed to update a ServiceWorker… Operation has been aborted". This error is handled, produces zero stack frames, and is never actionable. The existing `ignoreErrors` patterns in `initializeSdk.tsx` only cover fetch-abort variants and don't match the service-worker update message, so these events were leaking through to Sentry as noise. Guard the catch block in `useServiceWorkerUpdateCheck` to skip `captureException` for `AbortError`, consistent with how `api.tsx` already suppresses `AbortError` from request paths. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0195fxt7YcRVs51RoLXyfBiY
…ster Extends the previous fix to cover the `navigator.serviceWorker.register()` catch handler as well. The breadcrumb trail on the triggering event showed a companion error: AbortError: Failed to register a ServiceWorker... Operation has been aborted This comes from the `useRegisterServiceWorker` catch path and has the same characteristics: handled, zero stack frames, expected browser behavior when the user navigates away during registration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0195fxt7YcRVs51RoLXyfBiY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes noisy, non-actionable Sentry events caused by
AbortErrorbeing captured from service worker operations inserviceWorkerContext.tsx.Root cause (from a live Sentry alert):
Two
.catch()handlers inserviceWorkerContext.tsxcallcaptureExceptionunconditionally:useRegisterServiceWorker—navigator.serviceWorker.register()aborted:useServiceWorkerUpdateCheck—registration.update()aborted:Both arrive in Sentry as:
handled: yes(caught exceptions)DOMException.code: 20=ABORT_ERR— transient, browser-driven abort when users navigate awayWhy the existing
ignoreErrorspatterns don't catch them:initializeSdk.tsxalready ignores severalAbortErrorvariants (e.g.AbortError: The operation was aborted, Safari fetch-abort errors). The service-worker messages"Failed to update/register a ServiceWorker…Operation has been aborted"don't match any of those patterns, so these events leak through as Sentry noise.Fix:
Add
error.name === 'AbortError'guards to both.catch()blocks, silently discarding these expected browser-level aborts. This is consistent withapi.tsx, which already skipscaptureExceptionforAbortErrorfrom fetch/request paths.Evidence
c1533dbfe16d46bea35b5853e0a0d018aafec53a4f9743a6b57c69b0c2ab5071DOMException.code: 20confirmsABORT_ERRin both casesClaude session: https://claude.ai/code/session_0195fxt7YcRVs51RoLXyfBiY
Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.