Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pwa): update gracefully if missing clients info #679

Merged
merged 3 commits into from
Oct 14, 2021

Conversation

KaiVandivier
Copy link
Contributor

@KaiVandivier KaiVandivier commented Oct 12, 2021

I noticed a bug when testing out the new update UX from LIBS-237 / #672 in the dashboards app: in dev mode, loading the app uses the latest adapter code but still requires updating the service worker. The latest adapter code requested Clients info from the existing SW to determine if it should reload right away or show the reload confirmation modal for multiple tabs open, but the existing SW didn't contain the logic to respond to that request, and the Update action failed. (I don't think this should happen in production because the deployed app will use the old adapter code, which doesn't make that request)

This PR includes better handling in case the request for clients info fails for any reason, falling back to the reload confirmation modal if no response is received to prevent data loss.

Also, the logic for requesting clients info is improved somewhat to send the request to the most recent SW, which would have been able to respond correctly in the bug case described above. The timeout is decreased too, which improves UX in case of a failure.

If you want to test out a SW that doesn't respond to the getClientsInfo request to simulate an old SW while using the PWA app, you can comment out this line in service-worker.js and build the PWA package before starting the pwa-app again (or using the yarn build:pwa --watch command -- also for the adapter too)

@KaiVandivier KaiVandivier enabled auto-merge (squash) October 12, 2021 14:16
@varl varl changed the title fix(pwa): update gracefully despite missing clients info fix(pwa): update gracefully despite missing clients info Oct 13, 2021
@varl varl changed the title fix(pwa): update gracefully despite missing clients info fix(pwa): update gracefully despite missing clients info Oct 13, 2021
@KaiVandivier KaiVandivier changed the title fix(pwa): update gracefully despite missing clients info fix(pwa): update gracefully if missing clients info Oct 14, 2021
@KaiVandivier KaiVandivier merged commit c7fe509 into master Oct 14, 2021
@KaiVandivier KaiVandivier deleted the fix-update-with-missing-clients-info branch October 14, 2021 10:59
dhis2-bot added a commit that referenced this pull request Oct 14, 2021
## [8.2.3](v8.2.2...v8.2.3) (2021-10-14)

### Bug Fixes

* **cli:** run yarn install after fixing yarn.lock by deduplicating ([#676](#676)) ([a32f969](a32f969))
* **cli:** wrap App component in CustomDataProvider in boilerplate test ([#678](#678)) ([88be6eb](88be6eb))
* **pwa:** update gracefully despite missing clients info ([#679](#679)) ([c7fe509](c7fe509))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 8.2.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

3 participants