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

upgrade of full stack causes failures due to mismatched frontend/backend versions #3550

Open
brianmay opened this issue Jan 12, 2025 · 4 comments
Labels
bug Something isn't working cli Related to the dioxus-cli program

Comments

@brianmay
Copy link

brianmay commented Jan 12, 2025

I am finding that when the deployed version has been updated, the server function endpoints change and the client starts generating errors (it is still trying to access the old end points which are somehow hashed). This requires force reloading the client (e.g. shift click the reload button in Firefox IIRC). IIRC just clicking reload doesn't work.

Because everything is in the client, we are not downloading html pages with the correct references. And in any case it looks like the wasm is linked to directly without any hashing in the filename:

<link rel="preload" href="/./wasm/penguin_nurse_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="preload" href="/./wasm/penguin_nurse.js" as="script">

Which is OK for me, not OK if I want to deploy websites that others will use.

Is there any better way of handling this?

I don't think there is anything I missed in the docs on this, but I might have missed something.

Unfortunately, I don't think I can use Dioxus full stack for anything serious while this problem remains.

Originally posted by @brianmay in #3496

@ealmloff ealmloff added bug Something isn't working cli Related to the dioxus-cli program labels Jan 13, 2025
@ealmloff
Copy link
Member

This looks like the same issue as #3350 which will be fixed by #3531

@brianmay
Copy link
Author

Wonder if hashing the filenames is actually going to be sufficient here.

Problem is that the hashed filename is referenced in the index.html file. And the client is not necessarily going to load a new copy of the index.html file (unless something triggers it to do so like clicking the reload button) so it won't get the new hash.

@ealmloff
Copy link
Member

Wonder if hashing the filenames is actually going to be sufficient here.

Problem is that the hashed filename is referenced in the index.html file. And the client is not necessarily going to load a new copy of the index.html file (unless something triggers it to do so like clicking the reload button) so it won't get the new hash.

The index.html caching policy needs to be much more restrictive since we don't hash that name. Every time the page is loaded the browser needs to check it has the most recent version of the index.html file. If another asset changes, that should change the links in the index.html file and cause a refetch for the assets that change. Then every time the page is reloaded even if it isn't a hard reload, it should have the most recent version of all assets

For sessions that are when a new build is pushed it could be a good idea to serve the old version of assets for a while to make sure all sessions end and get the new index.html with the links to the new assets. This should be as simple as serving the old and new assets at the same time. Since the hash is based on the contents of each file, the old and new files should not conflict if they have different content. We don't have support for this in dx today, but it would be a good feature to add in the future

@brianmay
Copy link
Author

Keeping old assets might make builds more complicated, you need to have the old assets to build the new. Unless the deploy just copies assets to an asset folder somewhere that is regularly cleaned up.

More importantly though, this isn't going to help with server functions, which is where I am getting the errors. I have a copy of the wasm running on my phone, and do an upgrade of the server.

The phone continues running the old wasm without even considering trying to update the index.html file, and will try to make requests like http://localhost:4000/api/get_users11843745895277440839.

(am curious how this path is generated)

But this path is no longer valid for the server function. Instead it will point now to my Not Found handler (presumably; not tested) which will generate errors when the Not Found handler doesn't generate the expected json result.

I can't think of any good solutions though really. About the best I can think of is some sort of /get_version end point (not a server function that is hashed), and have the client regularly check that the version matches and if it doesn't then tell the user to reload. Or something like that.

Presumably, if you change the caching policy on index.html and have it point to a hashed filename for wasm, just a simple reload should be sufficient, no need for a forced reload (shift-click).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli Related to the dioxus-cli program
Projects
None yet
Development

No branches or pull requests

2 participants