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

show snackbar on update ready #316

Merged
merged 20 commits into from
Nov 12, 2022
Merged

show snackbar on update ready #316

merged 20 commits into from
Nov 12, 2022

Conversation

incognitojam
Copy link
Collaborator

@incognitojam incognitojam commented Nov 10, 2022

@adeebshihadeh
Copy link
Contributor

Can we just reload instead?

@incognitojam incognitojam marked this pull request as draft November 10, 2022 05:23
@incognitojam
Copy link
Collaborator Author

incognitojam commented Nov 10, 2022

I guess if we are OK with losing whatever state the app has at that time, then yeah, although I guess there isn't much state that isn't in the URL right now.

I'm also going to look into this a bit more because apparently it can cause bugs if for example multiple tabs are open and you switch service worker.
https://redfin.engineering/how-to-fix-the-refresh-button-when-using-service-workers-a8e27af6df68

@incognitojam
Copy link
Collaborator Author

incognitojam commented Nov 11, 2022

In Create React App, the default service worker installs updates immediately when available and discards the old cache, causing the "chunk failed to load" errors when the user tries to load other routes (#312) since they are still browsing on the old site with old JS/HTML referencing now non-existent resources.

We can fix this by adding our own service-worker.js which doesn't immediately call skipWaiting(). If we want to update sooner than waiting for all tabs to be closed, we can prompt the user and/or call skipWaiting() before reloading all open tabs.

@incognitojam incognitojam marked this pull request as ready for review November 12, 2022 01:34
@incognitojam incognitojam merged commit 0227e4b into master Nov 12, 2022
@incognitojam incognitojam deleted the sw-update-available branch November 12, 2022 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants