-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Not found /_app/immutable/assets/xxx #9089
Comments
My guess: You deploy a new version, the user is still using the old version and doing a navigation to a not-yet-loaded page where they need to request an asset (JS file or whatever), which then fails. It's more visible when turning CDN off since the CDN is caching the outdated assets from your previous deployment for a while. |
I think it is JS files only, but that's fine since any pages that are loaded for client-side nav also have a JS portion. When one of these requests fails with a 404, SvelteKit will automatically request |
Something we should document: you can detect version changes and proactively opt in to full page reloads by setting a <!-- src/routes/+layout.svelte -->
<script>
import { updated } from '$app/stores';
</script>
<main data-sveltekit-reload={$updated ? '' : 'off'}>
<slot />
</main> |
Firstly, excuse me for my ignorance, but I've been getting similar errors on Sentry for an app at work, and I've been tasked with investigating it (3 weeks in, currently writing a 3rd Notion document 😮💨). Seeing your response gave me a few questions about this. The docs for the
I appreciate any insight, and if this wasn't the appropriate place to ask, I can create a Discussion. This potentially could save me a lot of time, thank you! |
|
I think the built-in functionality for detecting an app update and switching to a full page reload may be unreliable in some cases. When the user gets a 404 on one of the chunks to be imported, I can see the call for __version.json but the user still goes to an error page when clicking on the link. I can see the errors in Sentry and I can confirm via Session Replay that the error page +error.svelte is indeed showing to the user instead of the page that the user wanted to navigate to. So it's not a false positive error report. This appears to happen randomly and I am unable to replicate it myself. But it's definitely happening for some users. The error is usually "Importing a module script failed" or "Failed to fetch dynamically imported module" -- so perhaps the client is still trying to load one of the files from the previous release? |
That's odd — those are the errors that usually lead to a request for |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
We are getting this error on our site hosted on Vercel. I've had two separate people report that they are getting a 404 error, even after refreshing the page. And the error in the console looks like this: If they open an incognito window, it loads fine. So I assume they have an old tab open like mentioned above. We have a webhook automatically re-deploying the branch on vercel after a few different events, such as updating a product in our ecommerce store, inventory stock level updates, or editing one of our marketing pages. I would say on average it is re-deployed once 30 minutes - 1 hour. Is it likely that the CC @Rich-Harris |
After following this, I got errors from all js file. So I made trick. I exchanged two values. <main data-sveltekit-reload={$updated ? 'off' : ''}> But it showed same results. I don't have deep knowledge, so just wish somebody can solve this issue. |
Just figured out what exactly is changing, all of the files Kit (or Vite, most likely) touches / creates always have a different hash, regardless of if Vite's hashes would stay the same. Here's a commit on a repro -> snuffyDev/sveltekit-hash-gen-repro@0343f72 To reproduce yourself locally:
The hashes change, and even the actual output does as well, even though the contents haven't? Is due to Vite building with rollup, or something? Here's a video showing what Vite's behavior looks like when building a library I work on (contents of the files haven't changed between builds -> hashes stay the same): 2023-05-07-23-06-36.mp4 |
@snuffyDev Are you setting a version name explicitly in your svelte config? Otherwise it defaults to the timestamp and as such every build will have a different version number embedded in it which will change the hashes for most chunks. |
Midnight Airhead moment 💀, slipped my mind that |
@gtm-nayan Assuming default svelte version.name config (i.e. timestamp of build), is it therefore intended that the hashes for most chunks change on every deploy, regardless of code changes? |
We certainly don't want that to happen, but I don't really see any other sane default that we can put either. We're assuming people won't usually deploy often without code changes. (css, js, even strings inside your js/svelte files are code changes).
The router regularly polls the version file to check if it has been updated and falls back to native navigation if it has. And you can use the snippet that Rich provided above in case you make use of a lot of dynamic imports. kit/packages/kit/src/runtime/client/client.js Line 735 in 51c0b3c
Users should probably base their versions on some version control identifier if available but the framework can't assume its presence. We could maybe try to use a hash of the vite manifest, but that has a chicken and egg problem of its own. |
I get this without fail every time for github pages. Why? |
Hey folks. We're facing this issue as well. Somehow it's originating from Sentry. Is there a workaround for this? Some of our users are affected. |
@Fasteroid @SubhamPramanik if you can share a reproduction, it would help with diagnosing the issue. |
@SubhamPramanik , what version are you running would help as well. |
hey @jycouet right now we are using "@sveltejs/kit": "^1.20.5", and error that is coming for us is attached below ![]() |
@jycouet @eltigerchino
[1] Dockerfile
[2] package.json
|
@SubhamPramanik thank you for sharing that info. Is it possible for you to also share what files are being cached / how the cache is setup? This seems to be a common factor with regards to the issue author's description |
This comment was marked as off-topic.
This comment was marked as off-topic.
Would like to add a new discovery to this, if you enabled Signed Exchanges in Cloudflare and your clicking on the links in Google Search Results to test this behavior as I was since that's where the majority of complaints were coming from, those links are not pointing to your site. They are pointing to a Cached version of your page on Google Exchange and this completely breaks SvelteKit for some reason, so you cannot use this feature with SvelteKit. You will need to disable this and then wait several days, weeks maybe for Google to drop your site from the Google Exchange network. |
Hi guys. In addition, i remove immutable cash line by using patch-package. |
This is causing a lot of issues on my end on each new version deploy. Setting the poll interval lower would probably help, but that means an extra few million monthly hits to handle (and to pay for, considering Cloudflare Pages pricing for example). I'm trying a lot of hacky things, but nothing works flawlessly yet. |
I'm confused why this is still an issue, and why it is not fixed at the vite or sveltekit layer. It seems like maaaany more people should be encountering this issue. |
I was able to mostly fix the issue on my side. I'm using CloudFlare Pages, and whenever I deploy a new version I just purge the cache for the entire domain using the CloudFlare API. Doing this fix the issue for all new users arriving on the app, and then the |
I'm also experiencing something similar. I'm deployed on Vercel using the vercel adapter. The initial SSR'd HTML loads correctly, but when we try to fetch the JS chunks, the browser decides to try to fetch them from the disk cache instead of loading fresh chunks, which causes unexpected behavior. I've tried:
I've noticed that version.json isn't even called as network event sometimes - I wonder if that's b/c the JS needed to do so isn't loaded properly? Thanks! |
I am still experiencing the same problem after I:
But some people still have the not found error. Anyone figured out a reliable solution? |
I'm having the same issue also and have tried everything under the sun related to https://kit.svelte.dev/docs/configuration#version to try to resolve this. Any ideas? |
If you clear your app's cache on each deploy, it works flawlessly. For example, on CloudFlare, use Caching -> Configuration -> Purge everything (or Custom purge). |
We're using Vercel without CloudFlare. Not sure if there's anything we can do with this setup to clear the app cache. |
Did you guys just have this happen on a site too? I did as well for one also running through cloudflare as a dns and cache provider. Wondering if their cache maybe had a minute |
Yes, that may be the case. For example, in addition to a litany or 404s for a bunch of files, including
The app's JS never loads. When I inspect the DOM, the only thing inside the body > div is the load script, which contains at the bottom:
There is no further HTML loaded from the root layout, etc. As you can see, the cached version is looking for |
@vecter - what does your |
It says either HIT or MISS depending on whether or not it can find the file. Apologies for my noobie question but how does that relate to this issue? I did a hard purge of the Vercel app's data cache but that didn't do anything. |
I meant, the |
It must be a browser caching issue. I can load that URL (https://staging-app.usemantel.com/_app/immutable/chunks/scheduler.66c77ea2.js) fine in an Incognito chrome window. However, in my main Chrome window where I've been doing all of my development work, I get the 404. I'm pretty sure it's b/c Chrome is trying to load it from the disk cache: The Status Code shows "404 Not Found (from disk cache)". It assume it's not in the cache because it's a new file from the most recent build. I don't know why Chrome doesn't try to fetch the file remotely. Maybe because the |
Can you adjust the |
Thank you for that suggestion. I will look that up and try that now. Will let you know how it goes. |
One thing: if I set it to |
You should set
|
That makes sense, thanks for spelling that out. I've scoured the Vercel docs on how to set the Cache-Control header conditioned on the response status code but I don't see how: https://vercel.com/guides/how-to-configure-the-cache-control-response-header-in-vercel-projects#using-the-vercel.json-file Am I totally missing something or is there a simple way to do it? |
I haven't played with Vercel much, so I do not know exactly how to do it. I'll give it a try later today and see what I can find. In the meantime, I also found that: https://vercel.com/docs/deployments/skew-protection. |
Thanks for the reference, I'll try that and see if it resolves the issue somehow (hard to tell currently if it's exactly related) |
If you find a way to |
Interesting, what do you mean by "clear the cache on the root page on every deploy"? I assume you mean the browser's cache of some files but I'm not quite sure. |
Like I said here, but I do not know how to do it on Vercel. I used to have the same bug you had when I deployed our app. Our error rate was skyrocketing on each deploy, but now it's 0% since we added a clear cache step on our deploy process. |
Describe the bug
We're hosting sveltekit with SSR in a Docker container that's hosted in azure. We have datadog to track errors and we tend to see about 3 to 30 of these 404's a day on our small-medium site.
We played around with azure cdn cache, but when we enabled this, the errors really came to show, so we disabled the azure cache. When doing so, it went back to it's normal occurance.
This issue is the same as this question posted a while ago; #7057
Example error for a 404 asset:
What might be the cause of this type of error, Is it just something that happenes when document is out of sync with assets, or is it something we can do to keep this from happening?
Reproduction
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: