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

[✨] Reload page when QRLs return a 404 after code has changed and been redeployed #3777

Open
DustinJSilk opened this issue Apr 14, 2023 · 9 comments
Assignees
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: enhancement New feature or request

Comments

@DustinJSilk
Copy link
Contributor

DustinJSilk commented Apr 14, 2023

Is your feature request related to a problem?

When a production codebase is updated, the urls to QRL can change. This means that the website breaks for all users that are currently on the website.

Requests to fetch each chunk abort with a 404.

This can be tested by running a preview server, changing the code and restarting it, then interacting with the website.

Describe the solution you'd like

Since QRLs are serialised into the html, my guess is that we would need to completely refresh the page to update them.
Unless there is a mechanism to refetch them.

It might be better to have an event/hook so that developers can decide what to do next when this happens.

Describe alternatives you've considered

We can't create aliases at build time because a user might have already loaded an out-of-date script which is incompatible with a newer version of another script.

This also didnt catch the aborted requests:

useOnWindow('error', () => {})

Additional context

This causes major issues with continuous integration.

@DustinJSilk DustinJSilk added TYPE: enhancement New feature or request STATUS-1: needs triage New issue which needs to be triaged labels Apr 14, 2023
@gioboa
Copy link
Member

gioboa commented Sep 14, 2023

Hi @DustinJSilk, with the latest version of Qwik, is it still a valid issue?

@DustinJSilk
Copy link
Contributor Author

Hi @gioboa, I havent tested it, is there a commit that has addressed the issue?

@gioboa
Copy link
Member

gioboa commented Sep 15, 2023

In my production app I saw a refresh because of that.
Now I'm trying to reproduce the case without success.

@gioboa
Copy link
Member

gioboa commented Feb 26, 2024

This PR #5521 solves the issue. Thanks @DustinJSilk for reporting it.

@gioboa gioboa closed this as completed Feb 26, 2024
@DustinJSilk
Copy link
Contributor Author

@gioboa this still exists for me. The browser can still get stuck having the JS files cached and returning 404s until the site data is cleared and the page is refreshed. No amount of refreshing helps until the cache is emptied.

Can we please reopen this the website can get completely bricked by this issue.

This was tested on v1.4.5 which was released after that code change. i will monitor this with v1.5.3 going forward as well.

@wmertens
Copy link
Member

wmertens commented May 3, 2024

That PR isn't sufficient, it's only for navigation, not for any other js loading.

@wmertens wmertens reopened this May 3, 2024
@wmertens
Copy link
Member

wmertens commented May 3, 2024

Note that 1.5.3 supports skew protection on vercel, which is another way of solving this, by making sure clients talk with a server that has their version.

Only works for 12 hours though, unless you pay more.

So the reload is still necessary.

@DustinJSilk
Copy link
Contributor Author

Thanks for giving this your time, @wmertens !!

It seems like there are 2 issues at play here:

  • The docs state: Each build will create a new service worker, and the old service worker will be automatically unregistered. So if the page is refreshed and there is a new app, the service worker should get replaced and there shouldnt be any outdated code running. This didn't work for some reason until the user cleared all site data in the dev tools.
  • The other issue is when the app gets updated after the page has already loaded and then the QRLs start returning 404s or failing due to updates to the server side code.

Could we achieve something similar to Vercel Skew Protection (Im not on vercel unfortunately)

  • In some middleware we set a cookie with a site version, if a request arrives with an old version, we return a redirect to a page that can do a refresh. This should reregister the SW and clear the cache. Though as mentioned above it seems like there might have been another bug causing it to not work.

It doesn't seem very elegant and Im not sure if theres a better Qwik way of doing this.

@PatrickJS PatrickJS self-assigned this May 4, 2024
@PatrickJS
Copy link
Member

PatrickJS commented May 4, 2024

@DustinJSilk if you're using aws or anything with s3 to host the files you can deploy everything in /build folder in the same /build folder. this will fix the preview/next file version issue for files. For routeAction$ you can pass id string value as a second object to map to the same routeAction$ even when version changes. I'll add id config to server$ and see if we can add something in the framework for others to figure out the skew versions.

for vercel you have a deployment-id in a cookie then for each request you just map the deployment-id to the correct location. because its a cookie this will also attach to any assets but I mention above the fix is just deploying everything in /build in the same folder on a cdn since everything in /build is immutable

if the app was pwa then the version of the app will be downloaded (but still have mismatch action/loader/server$)
https://github.com/QwikDev/pwa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants