CSS Not Loading When Rapidly Switching Routes

I recently came across a bug on my website where rapidly switching to different routes will not load the CSS of the page and hence looks like this. I have found something similar to this although in NextJS, however idk how to get rid of this bug since i don't have a lot of information to go by
GitHub
Issues · vercel/next-plugins
Official Next.js plugins. Contribute to vercel/next-plugins development by creating an account on GitHub.
30 Replies
McBrincie212
McBrincie212OP4mo ago
ig nobody gives a shit on how to provide hints to fix this
zulu
zulu4mo ago
where is the link to the website?
McBrincie212
McBrincie212OP4mo ago
rn its not hosted
zulu
zulu4mo ago
ok, do you see any error loading the css?
McBrincie212
McBrincie212OP4mo ago
wdym
zulu
zulu4mo ago
where is the css coming from is it a file? is there any errors when that file is loaded? is it aborted ? do you have any information that you think can help figuring out this bug? if you provide some useful information someone might be able to suggests things if this is not a common problem, you need to provide some more details
McBrincie212
McBrincie212OP4mo ago
give me a sec the closest thing i got to replicating it is deleting all of the contents of App.css
zulu
zulu4mo ago
when you inspect in devtools do you see a css file being loaded? in the network tab?
McBrincie212
McBrincie212OP4mo ago
well there are some but App.css along with some others aren't loaded they aren't present as <style ... />
zulu
zulu4mo ago
is it for a specifc route that you see it ? if you refresh does the css load for that route?
McBrincie212
McBrincie212OP4mo ago
yes
zulu
zulu4mo ago
yes for both?
McBrincie212
McBrincie212OP4mo ago
for the second for the first when i go from one other route to another rapidly it leads me up to the index route for example if im switching from B to C, it switches to A and same for B to A or C to A
zulu
zulu4mo ago
so it also goes to the wrong route?
McBrincie212
McBrincie212OP4mo ago
ye i tried to rapidly switch between localhost/documentation `and localhost/about which about leads to 404 then it switched me to just localhost/ if i do localhost/documentation with localhost/ same thing
zulu
zulu4mo ago
and for this to happen you need to do B to C to B quickly ? or in your case let say localhost/documentation localhost/about localhost/documentation then it goes to localhost/
McBrincie212
McBrincie212OP4mo ago
yes
zulu
zulu4mo ago
and you mentioned somethign about 404 when does that happen and why?
McBrincie212
McBrincie212OP4mo ago
for the 404 page, i just didn't define a route for about yet tho its not that
zulu
zulu4mo ago
so if you switch between routes without 404 you still see this?
McBrincie212
McBrincie212OP4mo ago
yes tho its from index to other route also here is what it loads when this bug happens
<head>

<style type="text/css"></style><style data-vite-dev-id=".../Project/src/components/sections/Hero.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/sections/StrengthsOFAPEL.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/CarouselCardComponent.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/sections/ExamplesSection.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/ExamplesVideoComponent.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/sections/InstallationSection.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/DropdownButton.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/CodeBlock.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/sections/RoadmapSection.module.css" data-vite-ref=“1”>…</style>
</head>
<head>

<style type="text/css"></style><style data-vite-dev-id=".../Project/src/components/sections/Hero.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/sections/StrengthsOFAPEL.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/CarouselCardComponent.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/sections/ExamplesSection.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/ExamplesVideoComponent.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/sections/InstallationSection.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/DropdownButton.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/CodeBlock.module.css" data-vite-ref=“1”>…</style>
<style data-vite-dev-id=".../Project/src/components/sections/RoadmapSection.module.css" data-vite-ref=“1”>…</style>
</head>
zulu
zulu4mo ago
so when this happen, it basically removes that app.css somehow? does it also happen in a production build or just dev build?
McBrincie212
McBrincie212OP4mo ago
i don't think i've tested for production build let me see for dev it does happen
zulu
zulu4mo ago
yeah, just to isolate to see if it not something with vite or something
McBrincie212
McBrincie212OP4mo ago
apparently it is something with vite in production build it doesn't happen at all so i guess we don't care
zulu
zulu4mo ago
I guess it is less of a problem, and unless someone can find the reason for this not much we can do about it
McBrincie212
McBrincie212OP4mo ago
ye at least good thing its in dev enviorement and not production i assume its bc im switching rapidly, some tasks get interrupted(including the CSS files) then they try to resume and they fail
zulu
zulu4mo ago
yeah, I will assume something similar somehow vite got overwhelmed / some race condition
McBrincie212
McBrincie212OP4mo ago
exactly btw sorry for the long delays
zulu
zulu4mo ago
not a problem 🙂

Did you find this page helpful?