Spoonie: handling blocked service worker registration
Reading a recipe should not depend on whether the browser can register a service worker. Spoonie’s earlier PWA setup had a potential failure path: when registration was blocked, Workbox-window could try to use an invalid registration object. Pull request #40, merged on November 13, 2026, changed that path.
Two places were handling registration
The next-pwa configuration used register: true for automatic registration. Spoonie also had a ServiceWorkerUpdater component to manage updates. A failure in the automatic path could happen before the updater had a usable registration.
The change sets register: false. ServiceWorkerUpdater now calls navigator.serviceWorker.register("/sw.js", { scope: "/" }) directly. It checks browser support and runs registration only in production. If the component has unmounted or registration yields no object, it stops the subsequent work. It also handles a rejected registration Promise locally.
The existing updatefound and controllerchange handlers still operate after a successful registration. Runtime caching remains configured.
Evidence from the deployed site
On November 14, 2026, the Spoonie homepage returned HTTP 200. Its served Next.js app/layout bundle contained the native /sw.js registration call, a result guard and a .catch() handler. The public code follows the approach in the merged implementation.
The pull request added two source-level regression checks for disabled auto-registration, retained cache settings and the manual updater. These are not end-to-end tests in browsers that block service workers. Changes in crash rates, completed recipe reads and retention have not been measured.
A useful check for other PWAs
MDN documents that register() returns a Promise and describes failure cases. A normal installation test does not cover a rejected registration.
The earlier viewer-scoped cache change focused on which account owns likes and saves in memory. This fix concerns the boundary between ordinary page access and optional PWA registration.