Skip to content

fix(login): reload on version mismatch to serve fresh assets#12538

Open
Nil20 wants to merge 19 commits intodevelopfrom
ocrvs-12497
Open

fix(login): reload on version mismatch to serve fresh assets#12538
Nil20 wants to merge 19 commits intodevelopfrom
ocrvs-12497

Conversation

@Nil20
Copy link
Copy Markdown
Contributor

@Nil20 Nil20 commented May 6, 2026

Description

Problem

Two separate issues cause infinite spinners after deployment.

Login app: On deployment, the cached JS bundle has an older APP_VERSION than the newly deployed gateway's X-Version header. The withRetry loop in index.tsx calls getApplicationConfig() before the app ever renders. When a version mismatch is detected, it throws VERSION_MISMATCH — withRetry catches it and retries silently forever, root.render() is never called, and the user sees a permanent blank loading screen.

Registration app: On mount, probeNetwork() in the V2 routes component immediately sets onlineManager.setOnline(false), pausing all TanStack Query queries. If the /api/ping probe fails (gateway briefly restarting during deployment), the catch block left onlineManager as false permanently. Queries with networkMode: 'online' never unpause, resulting in a blank/spinner screen in the workqueue area.

Fix

Login app (packages/login/src/index.tsx): On VERSION_MISMATCH, reload the page instead of retrying. The service worker uses skipWaiting() so the new SW is already active — a reload serves fresh assets matching the new backend. A sessionStorage counter caps reloads at 3 to prevent infinite reload loops in edge cases.

Registration app (packages/client/src/v2-events/routes/config.tsx): Move onlineManager.setOnline(true) into a finally block so it always runs regardless of whether the probe succeeds or fails. A failed probe means the server is temporarily unreachable — queries should still be allowed to run and handle their own retries rather than being permanently paused.

Checklist

  • I have linked the correct Github issue under "Development"
  • I have tested the changes locally, and written appropriate tests
  • I have tested beyond the happy path (e.g. edge cases, failure paths)
  • I have updated the changelog with this change (if applicable)
  • I have updated the GitHub issue status accordingly

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:

  • Changelog is read by country implementors who might not always be familiar with all technical details of OpenCRVS. Keep language high-level, user friendly and avoid technical references to internals.
  • Answer "What's new?", "Why was the change made?" and "Why should I care?" for each change.
  • If it's a breaking change, include a migration guide answering "What do I need to do to upgrade?".

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

ℹ️ Coverage metrics explained:
Statements — Executed code statements (basic logic lines)
Branches — Tested decision paths (if/else, switch, ternaries)
Functions — Functions invoked during tests
Lines — Source lines executed

@Nil20 Nil20 changed the base branch from develop to release-v2.0.0 May 6, 2026 10:41
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

📊 commons test coverage

Statements: 75.48%
Branches:   39.88%
Functions:  56.85%
Lines:      75.05%
Updated at: Fri, 08 May 2026 19:01:20 GMT

@Nil20 Nil20 marked this pull request as draft May 6, 2026 10:47
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

📊 events test coverage

Statements: 86.98%
Branches:   84.86%
Functions:  92.08%
Lines:      86.98%
Updated at: Fri, 08 May 2026 19:10:48 GMT

@ocrvs-bot
Copy link
Copy Markdown
Contributor

Your environment is deployed to https://ocrvs-12497.e2e-k8s.opencrvs.dev

@Nil20 Nil20 added the 🔒 Keep e2e Don't delete E2E environment after testing label May 6, 2026
@Nil20 Nil20 marked this pull request as ready for review May 6, 2026 13:52
@Nil20 Nil20 changed the base branch from release-v2.0.0 to develop May 6, 2026 13:53
@euanmillar
Copy link
Copy Markdown
Contributor

We get this in the client quite a bit too requiring a cache clear:
Screenshot 2026-05-06 at 14 56 26

Comment thread packages/client/src/v2-events/routes/config.tsx Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔒 Keep e2e Don't delete E2E environment after testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On every deployment an infinite spinner or errors block users from logging in without clearing cache in both login app and client

4 participants