LearnNewsExamplesServices
Frontmatter
id8690
titleOptimize ServiceWorker Update Transition
stateClosed
labels
enhancementaiperformancecore
assigneestobiu
createdAtJan 15, 2026, 2:08 PM
updatedAtJan 15, 2026, 2:19 PM
githubUrlhttps://github.com/neomjs/neo/issues/8690
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 15, 2026, 2:19 PM

Optimize ServiceWorker Update Transition

Closed v11.22.0 enhancementaiperformancecore
tobiu
tobiu commented on Jan 15, 2026, 2:08 PM

Users report blank pages during Neo.mjs version updates. The investigation reveals that the current implementation of onActivate performs synchronous, blocking cache deletion inside event.waitUntil(). This prevents the browser from handling fetch events until all old caches are deleted, leading to perceived hang times or blank pages.

Changes:

  1. Refactor onActivate to perform clients.claim() immediately and resolve waitUntil.
  2. Move cache cleanup logic to a dedicated cleanUpCaches method.
  3. Trigger cleanUpCaches asynchronously (fire-and-forget) after activation, ensuring the UI thread is not blocked during the update.
tobiu added the enhancement label on Jan 15, 2026, 2:08 PM
tobiu added the ai label on Jan 15, 2026, 2:08 PM
tobiu added the performance label on Jan 15, 2026, 2:08 PM
tobiu added the core label on Jan 15, 2026, 2:08 PM
tobiu referenced in commit 398b508 - "enhancement: Optimize ServiceWorker update transition (#8690)" on Jan 15, 2026, 2:18 PM
tobiu
tobiu Jan 15, 2026, 2:19 PM

Input from Gemini 3 Pro:

✦ I have optimized the ServiceWorker update transition to prevent blocking page loads.

Changes Implemented:

  1. Lazy Cache Cleanup: The onActivate handler now triggers cleanUpCaches() asynchronously without awaiting it inside event.waitUntil(). This ensures the Service Worker activates and claims clients immediately.
  2. Dedicated Cleanup Method: Added cleanUpCaches() to ServiceBase.mjs to handle the iteration and deletion of old versioned caches.
  3. Verification of Versioning: Confirmed that ServiceBase relies on this.cacheName (which appends this.version) to isolate caches per version (e.g., neo-runtime-11.21.0).

Impact:

  • Faster Updates: The new Service Worker will take control of the page almost instantly after installation.
  • No Blocking: The deletion of old caches (which can be slow) happens in the background, allowing network requests for the new version to proceed immediately.
  • Blank Page Fix: This should resolve the reported issue where users saw a blank page while the SW was busy deleting old files.

The changes have been pushed to dev.

tobiu assigned to @tobiu on Jan 15, 2026, 2:19 PM
tobiu closed this issue on Jan 15, 2026, 2:19 PM