-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Vite dev hangs indefinitely without errors on page with many components and imports #11468
Comments
I have also run into chrome spontaneously crashing (well just the tab) seemingly due to HMR but there was nothing useful that came out of verbose logging or anywhere else. When you say it stops working/hangs, what does it show in the browser? |
Nothing at all. Just a pending request and a spinner. The hanging only happens on requests to this 'route'/page, the vite process/server still accepts other requests even after the hanging happened. And handles them just fine without requiring a restart. I have no idea where to even start to 'debug' this problem. It does not seem chrome related, it happens in Firefox and Safari as well. |
I found a (consistent) way to temporary fix a hanging route.
Changing anything in one of the imported files (something as simple as adding a console log) can result in the HMR making the page hang again. |
I've run into infinite pending requests and other issues but here are a few thoughts that maybe will help you although what you describe doesn't sound exactly the same as what I ran into... Untrusted SSL/cache issues - for SSL we needed to have a trusted SSL certificate - it doesn't look like you're using SSL based on your screenshot but mentioning it just in case because there were equally frustrating and baffling issues with that. Using an untrusted SSL could lead to unexpected behavior since it wouldn't correctly cache anything. I see that 'Disable cache' is checked in your screenshot, and I wonder if that is maybe causing problems (or just a coincidence). Infinite pending requests - the infinite pending request problem that we had was caused by a bug in |
I have seen this as well, with SvelteKit. In my case I get a log that ssr compilation starts, but it never finishes. It is non-deterministic and only happens in dev. If you figure out what's causing it, I'd love to know— it's driving me crazy. |
Same problem here, but with a preact app that uses web workers with very large TS files (a parser). HMR is not my problem, though. I can run the app once. Have to wait a couple of seconds until everything is loaded. Then I go to the page that requires parsing and get a couple of these messages:
Once the last of the message is through I can actually use the page and the worker (pool) works. Then I try to restart the app and nothing works anymore. It just hangs and after a while I get a timeout error. When I now try to stop the dev server (by pressing q in the VS Code terminal) nothing happens. Same for ctrl+c. I have to kill the process and start the dev server again before I can continue. This is so annoying. If I only had a log that would tell me what's going wrong... |
Following the advice from @fc I disabled https and that seems to help with my issues. I used I then checked also HMR and the updates are instant! So https seems definitely to be an issue with the dev server/browser. |
@mike-lischke if you do need/want https, you need to trust the ssl by manually setting it to be trusted in Keychain Access on macOS. I had submitted a PR that added instructions/info about this on the troubleshooting page. |
Yes, I know. We do this automatically in our VS Code extension. But for the dev builds I hoped I could get away with that plugin and didn't expect such troubles once the browser accepted the connection. Thanks a bunch for your help @fc! |
Update: I removed the basic-ssl plugin and set up the dev server to use our (self signed) server cert. Everything connects and the page looks good at first look. But as soon as I start using the web workers I'm back to square one: after reloading the page or restarting the browser entirely, the web workers don't do anything anymore and the dev server just hangs. In fact it looks as if the dev server doesn't serve anything from this moment on. When I do yet another page refresh in the browser I only get a timeout error. |
I am also having the same issue. The dev server hangs seemingly randomly and the site is not accessible on subsequent restarts. The built version works fine but I'm unable to work on the project locally which is very annoying. I'm also using Sveltekit on a relatively big project so I cannot reproduce it. This leads me to believe that this might be a Sveltekit issue. Might not be related at all but I noticed that the site hangs each time after this message: |
I don't use Sveltekit and had to switch to non-secure connections (http) during debugging (which is not a big deal, just a bit annoying, having this working for such a long time, before I switched to vite). |
Based on this comment - has anyone tried using an older version of node (16.15 instead 18.x) - this could be a possible solution for the infinite pending requests in the network tab: |
@fc I am using v16.18.0. I tried 16.15.0 and the same thing still happens. I've been using the same version of Node all along and this issue started happening recently. |
I have exactly the same problem, and I've managed to solve it for my case, but I'm not sure if this the solution to every other case in this thread. So my problem was:
I'm developing on WSL on windows, and the localhost is routed to WSL. Hope this helps somebody ! |
I think I am having the same issue, ie. specifically when running the vite dev server the browser tab will hang on the initial load. However for me it is not just that the vite dev server is not responding, it seems like the browser tab is frozen, ie. when I press the close or back button on the tab in chrome it will not respond, and I need to press close many times to force close the tab from chrome. Is anyone else experiencing the same behavior in Chrome? Should also note that in my team I am the only non-Mac user, and none of the Mac users seems to be having issues. |
@roligheten That sounds like you have an infinite loop somewhere in your app. In this particular issue, the dev server fails to respond during server-side rendering. I am using SvelteKit and In my case, the // +layout.ts
// This runs but never resolves
const accountRes = await fetch(`/account/me.json`).then((res) => res.json()).catch(console.error);
// routes/account/me.json/+server.ts
export const GET: RequestHandler = async ({ request }) => {
// This function never gets called
}) |
The same here but on Chrome 109 for Linux. Firefox works, though Chrome 109 on MacOS also works fine. That's pretty annoying :) The project is quite large. Runing with Upd. Just tried Chrome 110 Beta on Linux with the same results. |
I tried versions 14, 16 and 18. It looks like Chrome problem, not the Node problem because it works on FF on all Node versions but hangs in Chrome only. |
So I found the fix (at least to my problem). This problem is similar to this one: In case you have a big project with plenty of files Chrome demands more file descriptors than system allows (1000 by default). I have Ubuntu Linux, so using so, for Ubuntu Linux you have to add line For Arch Linux they say to add Upd. LOL. Just figured out that |
Weird stuff. Using SvelteKit as well.
I can see the commit where this behaviour begins in my codebase. But nothing stands out. Here's the patch if anyone is curious, but it's just business logic changes relevant to my app (warning: large commit) (ignore the ruby code). I'll have to keep looking. UPDATE: just showed up again randomly. This time firefox requests don't help. |
Did you try what I suggested? Seems like that's a known issue but proposed fix doesn't work. |
Thank you @ximus This solved the issue for me 🥇 |
I am not on Linux, but on a Mac and Firefox has the same issue. In what way does #11959 close this? |
This resolved it for me. On MacOS, Sveltekit 2.0.0, Svelte 5.0.0-next.55, Vite 5.1.4 |
I had this same issue on a mac and this seems to have fixed it for now.. I searched around for how to check max files similar to the ubuntu linux fix and found this info for macs. |
Scratch that, its happening again. |
Same for Vite when building my Storybook documentation, both locally on MacOS, and in GitLab CI.
|
Thank you so much for this fix, works great. I noticed that Vite started to hang indefinitely only if the page uses a |
OK, I don't know what has been fixed, but after bumping Vite to |
the update did not resolve this issue for me, but the disable ssr in dev workaround suffices (for now) |
This is happening to me now starting with 5.2.0. If I drop down to the previous version, it works again. |
Can also confirm that dropping to |
I have had success with this PR: https://github.com/shYkiSto/vite/tree/fix-ssr-deadlock To get it running:
Then in your project folder run:
It will now use the local package instead of the registry package. |
I had same issue with sveltekit, fortunately I do not use ssr features, so I disabled ssr and prerendering as mentioned above. |
Having the same issue with SvelteKit and dropping to |
Seeing this issue suddenly on vite 5.2.10 hanging forever "transforming..." |
I have a similar issue (5.2.8 now, but tested 5.1.6 and 5.2.10), that happen whether I use It's like all of a sudden, Update 1 I went back in my code history to few previous version that worked and still nothing. However I noticed that vite does create files in the configured Update 2 I tried node Update 3 I tried outside my dev container and it worked without any issues. So, during the week I touched nothing, something happened between my dev containers and vite 🤔 Update 4 After a refreshing night, I tested to downgrade Docker from the new v26 to the previous v25 and it resolve my issue. Now, it's left to dig up what changed in Docker to make my dev containers not working correctly regarding the vite dev and preview server. Update 5 Under docker v26, my dotnet preview server seems to be working fine. So this issue seems limited to either Vite or whatever backend Vite is using for its server. I'll open another issue to track this one. |
This also resolved my issue. Node 20.11 |
I was hoping this would fix it, but it doesn't seem to have worked for me 😢 Update: I repackaged my monorepo dependencies and after restarting the server again, the server did run. I'm not 100% sure that this was the fix, but at least for me it seems to be a package issue with monorepos. |
Seems like a weird memory issue. I ran |
done round about every thing suggested on this issue , still no joy . I hope this gets fixed once and for all. |
We suffer from this at least more than a year. (OFC we tried every suggestion) We spent hours to debug it and it's very sneaky bug. Which can pain in the a** if you have to restart things frequently. |
Unfortunately, this doesn't work for me. I disabled SSR for all protected pages in my app when I started the project, and I still encounter this issue.
This also doesn't seem to be the case for me. At first that seemed fitting because I did not get this infinite loading state when accessing the root page or login page (both not containing any loops) as first route after (re-)starting the server, so I removed all each blocks from my dashboard page (and all child components it uses), but the page still ended in an infinite loading state after accessing it as first page after a restart. My current workaround is that when this deadlock happens, I navigate to my homepage (or the "/" route), kill the server, and then restart it. After accessing this page as the first one, everything works. Unfortunately, it only takes like 2-3 changes and I end up in this deadlock again. |
Thanks man! This DEV hanging happened twice now with barrel exports ... I'm not even sure why it went away previously (months ago). For context this is my current svelte and vite package versions: "@sveltejs/kit": "^2.5.7", |
@rogerfar how did you get past this error:
|
Just got bit hard by what I think is this bug which I think could be fixed by #15395. Thankfully I would like to make a repro in the next few weeks, but until then, I can share the general setup:
Whenever we'd save |
I think it is probably best if |
I think merging #15395 so circular dependencies are supported like they are in ESM would be best, so Vite does not always hang for its own reason when it finds a circular dependency. If circular dependencies are officially not something Vite supports, then I think a minor version bump to add a warning when one is detected and a major version bump to throw an error when it detects one would be second best. |
Describe the bug
I use SvelteKit. I have a somewhat complex page that contains quite a lot of components and imported functions. I had sporadic problems with this page hanging in the browser (both Firefox and Chrome). However, no error or notification in the vite cli. I was usually able to fix this by restarting the dev server several times whether or not in combination with restarting the browser. Other, simpler pages, always just kept working. Restarting my computer always works.
In recent days, I have been adding extra functionality, and the more I added, the more often the page kept hanging and the harder I got it to work again. When I get the page online (after frequently restarting everything I get restarted), everything just works. Until I make an adjustment in the code and because of the HMR the thing hangs again. I don't see any other pattern to it.
The problem does not occur when I build and preview the page, the production code always works.
It's driving me crazy, I can hardly get anything developed.
Reproduction
I can't build a reproduction, there is no pattern.
Steps to reproduce
It happens only on the dev server. I can find no pattern, cannot pinpoint a cause and thus cannot foresee any reproduction. There is nothing wrong with the code itself, the production build works perfectly.
The debug logs below are what I get when browsing to /leerlijn/54159.
It starts doing it's thing, and then just randomly stops at some point.
System Info
Used Package Manager
npm
Logs
Posted here: https://gist.github.com/hanszoons/2c511fa66ad76bd5181f84f7f7115eb5 because of the maximum 65536 characters.
These are the logs when requesting the page /leerlijn/54159, after wich it simply hangs indefinitely.
The second file are the logs when the page is rendered successfully. Same exact code, same config, same everything. Just some dev server restarts and good luck. 1 code change with HMR and the thing hang again.
Validations
The text was updated successfully, but these errors were encountered: