Skip to content

feat: harden service worker cache invalidation and update prompts (#680)#688

Open
knoxiboy wants to merge 1 commit into
Shruti070107:mainfrom
knoxiboy:feat/issue-680-sw-hardening
Open

feat: harden service worker cache invalidation and update prompts (#680)#688
knoxiboy wants to merge 1 commit into
Shruti070107:mainfrom
knoxiboy:feat/issue-680-sw-hardening

Conversation

@knoxiboy

Copy link
Copy Markdown

Description

Resolves #680

This PR hardens Service Worker registration update handling. It wires listeners for updatefound and statechange events, detecting when a new service worker transitions to the installed (waiting) state. It then displays a floating toast/prompt alerting the user that a new version of ReGenX is available and offers a "Reload" button to trigger activation.

What changed

  • Added showUpdatePrompt and wired check for reg.waiting on load inside src/app.js.
  • Implemented updatefound update triggers to detect when a new worker becomes available.
  • Removed duplicate registration of /service-worker.js at the end of src/app.js.

Why

When the Service Worker is updated with new modules, files in the cache might mismatch with active client modules, leading to blank screens or load crashes if not immediately activated and reloaded.

How to test

  1. Modify service-worker.js or change CACHE_VERSION value.
  2. Load the application in browser.
  3. Verify that the "Update Available!" toast with a reload button is displayed once the new service worker installation completes.

Checklist

  • Tested changes locally
  • No lint/syntax errors introduced
  • Matches all issue criteria

Files Affected

  • src/app.js

@knoxiboy knoxiboy closed this Jun 13, 2026
@knoxiboy knoxiboy force-pushed the feat/issue-680-sw-hardening branch from cbcf77d to b260e7b Compare June 13, 2026 11:18
@knoxiboy knoxiboy reopened this Jun 13, 2026
@knoxiboy

Copy link
Copy Markdown
Author

@Shruti070107 Please review this pr and merge it

1 similar comment
@knoxiboy

Copy link
Copy Markdown
Author

@Shruti070107 Please review this pr and merge it

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.

[BUG] Harden Service Worker Cache Invalidation to Prevent Blank Screen Modules Mismatch

1 participant