Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Intermittent HTTP 504 Gateway timeouts fixed by restarts #8146

Unanswered
fatso83 asked this question in Q&A
Discussion options

Every so often, I get some HTTP 504 after starting up Vite. By killing Vite and restarting (sometimes 2-3 times), the error goes away. No changes in package.json, lock files or anything. It is always the same packages. Anything that could explain this behavior? It is livable, but also quite annoying for the entire team. Have been seeing this for the last 8 months.

Has been going on since Vite 2.6. Now on 2.9.1
Packages: tcomb, day.js

2022年05月12日_15-29

You must be logged in to vote

Replies: 11 comments 18 replies

Comment options

This command fixes it for me node ./node_modules/esbuild/install.js. Found the command on this thread #1361 (comment)

Not sure why its occurring or how to fix it permanently. Im on npm version 6.14.16

You must be logged in to vote
2 replies
Comment options

YOU SAVED MY LIFE
Thanks

Comment options

that's one of the many things that is trigged when just doing npm rebuild btw.

Comment options

Still getting this on Vite 4 😢
image

You must be logged in to vote
3 replies
Comment options

Deleting all my node_modules and reinstalling them, with yarn in my case, worked for me!

Comment options

The esbuild command mentioned above fixes the issue and is way faster than reinstalling all modules, so you should check it out. I just revisited my own thread to mention the fact that this still is an issue in Vite, two major versions later.

It is obviously related to esbuild somehow, but I remember digging into Vite internals earlier to figure out some other issue and it really burns some hours each time, so will wait this one out for now :)

Comment options

i don't have esbuild installed in my project, running the above node command don't do anything and gives not found error.

Comment options

I'm using Vite 4.2, npm 8.11 and Opera as the browser. If I go incognito or just use another browser I don't get the error. I have to reinstall node_modules every time I restart Vite. The node ./node_modules/esbuild/install.js command doesn't work for me. I tried clearing the site data in Opera but no success.

You must be logged in to vote
6 replies
Comment options

I happened for me again now, but changing browser and trying "private browsing" did not work, still got the same errors everywhere. For me, it works to just start vite again, I don't need to reinstall or remove any node_modules directory.

Comment options

Had the same issue on Vite 4.1.4 today. Adding optimizeDeps.force: true to my config seems to fix it, but that's not a great long term solution

Comment options

In my case I tried to delete all data related to the website, no success, but after a couple of days the error stopped appearing. So for me it must have been the cache or something related entirely to the browser memory data.

Comment options

@Dyoma3 Did you try the npm rebuild fix mentioned?

Comment options

No, I didn't. For me, the issue just suddenly disappeared.

Comment options

It seems to mostly happen when switching between branches. This could possibly affect the dependencies, but I am not sure if it is. In any case, most such issues seem to go away by running npm rebuild. This invokes the esbuild command mentioned by me above (amongst other things) and is much easier to get right, as that does not work the same if you use Yarn or PNPM.

You must be logged in to vote
0 replies
Comment options

Add the dependency like this to vite.config:

const optimizeDeps: DepOptimizationOptions = {
 include: ['@react-pdf/renderer'],
};
You must be logged in to vote
1 reply
Comment options

Tjena. How is this a general answer? Could you explain how you think that works, as most people do not have that dependency.

Comment options

This seems to be happening more often when two Vite processes are running at the same time, at least when the two are processing some of the same source code. (I actually wasn't able to reproduce the problem in our codebase when only running one of our two Vite instances, @fatso83 and @hcf ).

You must be logged in to vote
1 reply
Comment options

This appears to be the case for me as well. Never get this just running one Vite process. Not sure what a reliable solution would be however.

Comment options

Hey, I was actually facing this 504 error where my site was showing a blank screen. As I am new to web dev and digital ocean platform, I have had no idea of how to fix the error. But I fixed it for my problem as my site is static and I was trying to deploy it as a web service. So changing the type to 'static website' fixed my issue. Thought of adding an answer and to thank you for providing the idea of the kinds of error and solutions.

Thank You,

You must be logged in to vote
0 replies
Comment options

For me it helped to clear the file system cache by running rm -rf node_modules/.vite and then restarting the dev-server.

You must be logged in to vote
4 replies
Comment options

Did you try npm rebuild by any chance? Wondering if this is just implicitly handled.

Comment options

Before 5 this helps but still happens in vite 5

Comment options

@fatso83 what rebuild are you talking about? what is the actual command of that npm script? Bare vite project does not have rebuild script

Comment options

@deathemperor That is the actual command. Hence the syntax highlighting - try it before asking next time ;) This has nothing to do with Vite. It is a basic NPM lifecycle script that has to do with the installation of packages. See https://docs.npmjs.com/cli/v6/commands/npm-rebuild for more info.

It will ensure that packages that have build steps like gyp packages are being built properly for your current Node version.

Comment options

Found out that browser's hard reload (Cmd+Shift+R on Mac) helps.

You must be logged in to vote
0 replies
Comment options

This is still an issue in Vite 5.4.3

You must be logged in to vote
1 reply
Comment options

Do you have multiple Vite processes running, by any chance? That was the case for us. We could never reproduce this with a single Vite process running.

Comment options

Still an issue in Vite 7.1.10, and only for one user...

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /