Skip to content

fix(service-worker): skip Sentry capture for AbortErrors from update checks#119459

Draft
billyvg wants to merge 2 commits into
masterfrom
claude/serene-cannon-6wxz4o
Draft

fix(service-worker): skip Sentry capture for AbortErrors from update checks#119459
billyvg wants to merge 2 commits into
masterfrom
claude/serene-cannon-6wxz4o

Conversation

@billyvg

@billyvg billyvg commented Jul 11, 2026

Copy link
Copy Markdown
Member

Summary

This PR fixes noisy, non-actionable Sentry events caused by AbortError being captured from service worker operations in serviceWorkerContext.tsx.

Root cause (from a live Sentry alert):

Two .catch() handlers in serviceWorkerContext.tsx call captureException unconditionally:

  1. useRegisterServiceWorkernavigator.serviceWorker.register() aborted:

    AbortError: Failed to register a ServiceWorker for scope ('https://<org>.sentry.io/') with script ('https://<org>.sentry.io/service-worker.js'): Operation has been aborted
    
  2. useServiceWorkerUpdateCheckregistration.update() aborted:

    AbortError: Failed to update a ServiceWorker for scope ('https://<org>.sentry.io/') with script ('https://<org>.sentry.io/service-worker.js'): Operation has been aborted
    

Both arrive in Sentry as:

  • handled: yes (caught exceptions)
  • Zero stack frames (no debugging value)
  • DOMException.code: 20 = ABORT_ERR — transient, browser-driven abort when users navigate away

Why the existing ignoreErrors patterns don't catch them:

initializeSdk.tsx already ignores several AbortError variants (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 with api.tsx, which already skips captureException for AbortError from fetch/request paths.

Evidence

  • Triggered by Sentry alert event ID c1533dbfe16d46bea35b5853e0a0d018
  • Breadcrumb in that event shows companion registration abort event aafec53a4f9743a6b57c69b0c2ab5071
  • DOMException.code: 20 confirms ABORT_ERR in both cases

Claude 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.

…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
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jul 11, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants