fix: make update checks resilient to stale registrations#333
Conversation
Sentry Preview Error TriageNo Sentry errors found for this PR's preview deployment as of Tue, 23 Jun 2026 15:21:45 GMT. This comment updates automatically after each push. |
Code Coverage OverviewLanguages: JavaScript JavaScript / code-coverage/vitestThe overall coverage in the branch remains at 27%, unchanged from the branch. Show a code coverage summary of the most impacted files.
Updated |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d3e2a7869
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e7772f0bc9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Deploying with
|
| Status | Preview URL | Commit | Alias | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! | https://pr-333-charm.justin-tech.workers.dev | 01c4806 | pr-333 |
Tue, 23 Jun 2026 15:24:38 GMT |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 988cc4f24d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (directRegistrations.length > 0) { | ||
| return directRegistrations; | ||
| } |
There was a problem hiding this comment.
Keep unrelated registrations out of the fallback
The fresh path is this fallback after the scope filter: when getRegistration() has not found Charm's registration yet but getRegistrations() returns only registrations whose scopes do not match the current URL (for example, first load on an origin that also has a /legacy/ service worker), this returns those unrelated registrations instead of falling through to ready or reporting no app registration. The later pending/update/apply checks can then surface or message a worker that cannot control this page, reintroducing the out-of-scope registration problem whenever no matching scope is present.
Useful? React with 👍 / 👎.
Description
Make app update checks inspect every available service worker registration instead of only the current
getRegistration()result, so stale registrations can no longer hide a deploy until the user clears caches manually.Fixes #327
Related to #320
Type of change
Checklist:
AI disclosure:
This PR changes
checkForAppUpdates()andapplyPendingAppUpdate()to gather the app's known service worker registrations fromgetRegistration(),getRegistrations(), andready, dedupe them by scope, and then detect/apply pending updates across that full set instead of trusting one potentially stale registration. The tests cover the new stale-secondary-registration cases for both detection and apply so a hidden waiting worker still surfaces the update banner and the About action can apply it.