Failed to fetch errors on production
I'm capturing client exceptions on the server. Examples:
I suspected Vercel skew. Per Vercel docs and the SvelteKit Vercel adapter, I set a cookie containing the current deployment ID so clients hit the correct deployment.
my code for skew protection
I also send the deployment ID with each error to verify clients are on the latest deployment, so this doesn't look like a skew issue. Still, I keep getting
Failed to fetch
errors. I tried httpOnly: true
and false
with no effect. I can't reproduce locally — only remote clients report it, even with modern Chromium user agents.
Originally posted: https://discord.com/channels/722131463138705510/910635844119982080/141026972677230183511 Replies
I’ve been thinking about this.
Where is that setCookie from?
Are you sure the requests of the assets contain the cookie?
yes i am sure that request for asset contains the cookie

the set cookie is from vercel skew docs
https://vercel.com/docs/skew-protection
and its runing at the topest layout file with deferStream
i am thinking to turn on https://nitro.build/config#inlinedynamicimports
there is no change in the build, it still produces same files
And can you also confirm that the asset is matching the deployment_id?
I have the feeling that the VERCEL_DEPLOYMENT_ID gets updated, because there may be actions without revalidation keys which will invalidate all queries and update VERCEL_DEPLOYMENT_ID.
Anyways a suggestion would be to put that function in the
entry-server.tsx
so it only runs once on each initial request, file like
Yes i thought so,
I moved the code in entry-server.tsx
But still getting these errors
Failed to fetch dynamically imported module: https://groceryclub.shop/_build/assets/index-D0n0UOzW.js
This is my code in entry-server.tsx
Getting these errors by customers (they might still be on an old deployment) or by youryelf?
true they might be on old deployment, getting these errors from users
these links are 404 in current deployment https://groceryclub.shop/_build/assets/index-D0n0UOzW.js
this request is coming from a deployment made a day ago and that makes sense cause vercel only do skew protection for 12h
then what can be the solution for this ?
i think quick fix can be if error contains fetch failed then we should hard reload
Yeah either this or in your root layout inside onMount you put a setInterval which revalidates a server function that fetches the current deployment ID and compares it with the one in the cookie. If they don’t match you can do the hard reload.
Interval could be something like 11:50 hours to avoid running out of the deployment skew.
Additionally add a eventlistener e.g.
alright, i get the whole issue now.
i did some tests and find out that even skew protection was on, it was returning 404 for old files. after i cleared the cache in vercel, skew protection started working.
so this confirms that clients are either running on latest version with no errors or client running on some version where skew expired after 12 hours
so all the errors i am getting now on server are users that running version created before 12 hours.
i just need to implement that version checker and then show a notification to user that new version avilable, reload now
also whenever i get these dynamic failed errors i should hard reload by JS
thanks @Madaxen86 for all your help :v