Skip to content

fix(frontend): surface service worker registration failures - #431

Merged
dark-sarge merged 2 commits into
arflexx:mainfrom
Zuliyat:fix/issue-285
Oct 1, 2026
Merged

dark-sarge merged 2 commits into
arflexx:mainfrom
Zuliyat:fix/issue-285

Conversation

@Zuliyat

@Zuliyat Zuliyat commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Closes #285

Service worker registration failures were hidden from developers and monitoring. This surfaces them without breaking graceful degradation.

Changes

  • app/lib/monitoring.ts — a minimal, no-throw reportError(error, context) seam. Logs locally and forwards to a monitoring service if one is attached to globalThis (Sentry-compatible or window.__AIRFLEX_MONITOR__); safe no-op otherwise; SSR-safe.
  • components/ServiceWorkerRegister.tsx:
    • On failure: console.warn + reportError(err, { source: "service-worker" }).
    • A development-mode warning explains why registration was skipped (production-only; next-pwa emits /sw.js only in production builds).
    • A missing navigator.serviceWorker warns and degrades gracefully instead of throwing.

Note on the premise

main did not have a literally empty catch — it already called console.error. This PR implements the issue's actual asks: console.warn, forwarding to monitoring when available, and the dev-mode explanation.

Tests (components/ServiceWorkerRegister.test.tsx) — 4 passed

  • No navigator.serviceWorker → nothing registered, no throw.
  • register rejects → console.warn called, reportError invoked, no throw.
  • register resolves → no warning.
  • Development → explanatory warning, no registration.

)

The registration path hid failures from developers and monitoring. Report them
properly while keeping the app working without a service worker:

- failures are logged with `console.warn` and sent through a new
  `reportError` seam (`app/lib/monitoring.ts`) that forwards to a monitoring
  service when one is attached to `globalThis` (Sentry-compatible or
  `window.__AIRFLEX_MONITOR__`), and is a safe no-op otherwise;
- a development-mode warning explains *why* registration was skipped
  (production-only; next-pwa emits `/sw.js` only in production builds);
- an environment without `navigator.serviceWorker` warns and degrades
  gracefully instead of throwing.

Note: the catch was not literally empty on `main` (it logged via
`console.error`); this implements the issue's asks — `console.warn`,
monitoring forwarding, and a dev-mode explanation.

Closes arflexx#285
@Zuliyat
Zuliyat requested a review from dark-sarge as a code owner September 30, 2026 11:29
@drips-wave

drips-wave Bot commented Sep 30, 2026

Copy link
Copy Markdown

@Zuliyat Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@dark-sarge
dark-sarge merged commit 9027dea into arflexx:main Oct 1, 2026
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.

[frontend] - ServiceWorkerRegister silently swallows registration failures with empty catch block

3 participants