Frontmatter
| id | 8494 |
| title | Investigate and Fix Service Worker Cache Update Flakiness |
| state | Closed |
| labels | bugaicore |
| assignees | tobiu |
| createdAt | Jan 10, 2026, 11:01 AM |
| updatedAt | Jan 10, 2026, 11:46 AM |
| githubUrl | https://github.com/neomjs/neo/issues/8494 |
| author | tobiu |
| commentsCount | 2 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Jan 10, 2026, 11:46 AM |
Investigate and Fix Service Worker Cache Update Flakiness

tobiu
Jan 10, 2026, 11:12 AM
Input from Gemini 3 Pro:
✦ Correction on Risk Assessment: The failure mode is not just users getting stuck on an old version; the critical risk is that the update process can fail midway, leaving the user with a blank page. This elevates the severity of this issue significantly.
tobiu assigned to @tobiu on Jan 10, 2026, 11:21 AM

tobiu
Jan 10, 2026, 11:46 AM
Input from tobiu:
◆ I have implemented a fix to harden the Service Worker lifecycle and prevent cache poisoning.
Changes:
- Prevent Cache Poisoning: Refactored
onFetchinsrc/worker/ServiceBase.mjsto only cache responses withresponse.ok(status 200-299) orresponse.status === 0(opaque responses). This prevents 404s or 500s from polluting the cache during deployment windows.- Lifecycle Hardening: Added
event.waitUntil()toonInstallandonActivatehandlers. This ensures the browser does not terminate the Service Worker before it has finished critical tasks likeskipWaiting(), claiming clients, and cleaning up old caches.- Removed Aggressive Reload: Removed the
updatefoundlistener insrc/main/addon/ServiceWorker.mjsthat triggered an immediate page reload. This prevents jarring user experiences where the page would reload unexpectedly when a new version was detected.- Async Message Handling: Updated
onMessageto supportevent.waitUntil()for asynchronous message handlers, ensuring promises resolve correctly before the event is considered complete.These changes should eliminate the "blank page" risk by ensuring only valid assets are cached and that the Service Worker transitions states reliably.
tobiu closed this issue on Jan 10, 2026, 11:46 AM
The Service Worker update mechanism is inconsistent. While a version bump in
ServiceWorker.mjstriggers a new SW installation, the takeover process is flaky. Users sometimes require multiple reloads or manual DevTools intervention to clear the old cache and load the new version.Risk: A "blank page" scenario for first-time or returning users after a deployment.
Goal: Ensure a robust, zero-friction update strategy where the new Service Worker takes over immediately and reliably clears outdated cache assets.
Investigation Areas:
skipWaiting()andclients.claim()implementation.activatephase.