-
Notifications
You must be signed in to change notification settings - Fork 32
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
Unable to load some site assets. #78
Comments
I'm back with a bit of a clarifying example. Here's the persistence issue as we understand it:
For example: we have a "Stats" component in the top banner of our page that gets loaded when the user lands on the app. If a user loads our app and then tries to navigate to our "NFT Drops" page after we change the "Stats" component in our newly-deployed build, that asset hash will change and the user will start experiencing the problems above. I hope this helps find some solution. |
@TimTinkers That example is definitely useful! I don't think Vitedge is doing anything special with assets, it's just leveraging Vite and Wrangler. I didn't have time yet to check myself but here are some pointers:
The previous options will build your assets without hashes at the Vite level. I'll try to check when I have some more time but let me know if you find something. |
Hi @frandiox thanks for the added information, we're still continuing out own debugging. Just curious if you've had any additional time yet to look at this one. |
@TimTinkers hey! Not yet, quite busy here moving apartments and stuff. Still in my list though! |
@TimTinkers Hello! Did you manage to find a workaround on your end? I don't think this issue can be fixed in Vitedge easily because it's basically how SPA work. Once the old assets are removed from CDN, live users who don't yet have the new app version will need to refresh their browser to get it. What we did once in a Vue SPA app (on Netlify) was something like this: router.onError((error) => {
// When a new version of the app is deployed, old version's files are
// removed from CDN. Browsers that have old files cached will try to
// download more old files on route navigation.
// This will hard refresh browsers that fail when loading files in
// order to get the updated version of the app.
if (/loading chunk chunk-(\d|[a-z])+ failed\./i.test(error.message)) {
const key = 'chunk-failed-reload'
const lastReload = localStorage.getItem(key) || 0
// Do not reload more than once a minute to avoid infinite loops.
if (lastReload < Date.now() - 60000) {
localStorage.setItem(key, Date.now())
window.location.reload()
}
}
}) This basically detects the error and refreshes the browser. In this case, it was something like |
Hi @frandiox thanks for the reply! No, we unfortunately haven't had time to continue working on this project and didn't end up resolving this one on our end. Thanks for the tip though regarding the CDN assets, that makes sense. We'll keep looking into it. |
The issue we are experiencing is one related to KV assets. For context: our site is a Vue 3 application. We are building it using Vitedge to support SSR running on a Cloudflare Worker.
The issue as reported by one of our devs:
We deployed our application using Vitedge. In doing so, we deployed a new worker and KV: - Worker: test-assets
- KV: __test-assets-workers_sites_assets (c46d5f240d0643fe9f822ae3a25595de)
We opened the page that the Wrangler GitHub action had spun up for our Worker: https://test-assets.superfarm.workers.dev/ in incognito mode and waited until
test-assets
redeployed, then navigated to one of our pages ("NFT Drops") and experienced some HTTP 500 errors that some of our assets could not be found.- https://test-assets.superfarm.workers.dev/assets/Stats.af469f3b.js
- https://test-assets.superfarm.workers.dev/assets/index.b28d30af.js
- https://test-assets.superfarm.workers.dev/assets/ViewDrop.e0204051.js
- https://test-assets.superfarm.workers.dev/assets/Banner.e6440b01.js
{
"name": "Error",
"message": "internal error",
"timestamp": 1642042501244
}
],
The actual asset name:```
$ wrangler kv:key get assets/Stats.af469f3b.9ec2057bc5.js --namespace-id c46d5f240d0643fe9f822ae3a25595de
The text was updated successfully, but these errors were encountered: