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
Websocket server disconnects clients too early causing reload loop #3831
Comments
Duplicate #3803 |
@alexander-akait Is it a true duplicate? I see no mention of these details in the other one. Nothing about that commit or the heartbeat timer for the Websocket server? |
If you don't think it is the same please provide example, please avoid pointing to code, in your link nothing was changed, it is just internal refactor, problems like |
Raising the timer value never solves the problem, since the delays on your side may increase in the future and the problem will reappear |
@alexander-akait In the description above I mention that the heartbeat timeout has been changed from 30 seconds to 1 second, which is too short in big projects. This detail is not an internal refactor, but a big change that causes the reload problems for us. I've analyzed this in a detailed manner locally, reproducing it with this commit and not the previous commit. I reproduce it with I recognize that this is a timing issue, but is it a working assumption that the page will always on all computers load within 1 second? Having a higher timeout would make this much more stable either way. |
To dive into the timing change more, what is the reason for picking 1 second instead of 30 seconds? What would be the downside from having a higher value? |
higher value is not fix the problem, delay can be more on your side, there is no point in reasoning about value... |
Something wrong in state maybe, and we should improve checks, like no try to reconnect, if web socket is not connected or something else |
@alexander-akait Is there a common case where pages take 30 seconds to load, compared to more than 1 second? If there is little downside to putting a higher value, and less users of Webpack will have reload issues, I'm thinking it may be a worthwhile tradeoff? If the timeout can't be changed, what do you suggest as another solution for the problem? The problem is the timing specifically. The page takes some time to load up all the things, so I'm not sure what else would be a working solution. |
as you can see we have |
A new option would be great, if that allows us to keep using Webpack! 👍 🙏 If you see this as a workaround, what would a proper solution be? |
Need fix our runtime logic, I describe it above, why dev start starts slow, do you have something non standard? |
Ah okay 👍 It’s a big complex app, and things take a bit of time to initialize. Not much more though. 5 seconds heartbeat was fine in my testing, 1 second was not. My guess is that it takes up to a couple of seconds or so. The duplicate issue you linked to does seem similar in the sense of us also having multiple configurations exported from the main configuration. One of them is a dev server configuration that is there to start up the dev server for serving all the other ones. We have multiple apps on the same domain, with shared UI between the apps, so it makes sense for us to build all apps together. This does work very well for us and has for a long time. The only problem we have is the heartbeat timer that is now disconnecting the client. So, while I can’t speak for the setup of the author of the other issue, they do seem related. The other issue talks about building libraries used by an app, while this is building multiple apps. I’m open to either change here:
If you believe the slowness comes from running one dev server instead of one per app, any solution for that case would also work! 👍 I do believe however that 1 second can be optimistic to work for all project sizes on all computers under varying load. So even with something else, providing an option for changing that timer value could be useful. If you prefer to move the conversation to the other issue, that’s fine too. I just wanted to make sure the details in this issue were not lost, as the other issue didn’t mention anything about timing at all. Thank you! |
Will be great if you provide steps to reproduce, it will allow to fix problem very fast |
Sorry, tried different solutions and can't reproduce infinity loop, please provide steps to reproduce and I will reopen |
Maybe problem |
Thanks for testing! 🙏 I put together a small reproducible test case here: https://github.com/koggdal/webpack-dev-server-issue-3831-demo As mentioned, this issue is similar to the other issue you linked (maybe even the same), and I mainly wanted to bring the attention to the details covered in this issue around the commit that started the issues. It does seem to be related to the multiple configuration setup, as the reload seems to happen more often when more configs are added in the entry file ( What's interesting is that changing the heartbeat timer value has no effect now that I'm trying with this test repo (it did fix it every time I tested it in our real setup though). So I'm not sure what the involvement of that timer is for this issue, but maybe it can affect something. If this is in fact not really caused by that heartbeat timer, do you see what it could be caused by, and how it could be fixed (on your side or our side)? |
Give me time, I will look |
404, maybe private? |
Oh yes, sorry about that! Changed to public now 👍 |
Interesting, dev server is thinking it is no initial build due different values |
Does your build depended, i.e. |
And as I understand |
And yes, it is duplicate of #3803, shorty - let's take for example Three solutions:
|
Code
No code available for this issue, see description further down for details.
Please paste the results of
npx webpack-cli info
here, and mention other relevant informationSystem:
OS: macOS 11.4
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Memory: 22.59 GB / 64.00 GB
Binaries:
Node: 14.17.5 - ~/.nvm/versions/node/v14.17.5/bin/node
Yarn: 1.19.1 - ~/.yvm/.yarn/shim/yarn
npm: 6.14.14 - ~/.nvm/versions/node/v14.17.5/bin/npm
Browsers:
Chrome: 93.0.4577.63
Firefox: 91.0.2
Safari: 14.1.1
Monorepos:
Yarn Workspaces: 1.19.1
Packages:
compression-webpack-plugin: 8.0.1 => 8.0.1
css-minimizer-webpack-plugin: 3.0.2 => 3.0.2
html-webpack-harddisk-plugin: ^2.0.0 => 2.0.0
html-webpack-plugin: 5.3.2 => 5.3.2
terser-webpack-plugin: 5.2.3 => 5.2.3
webpack: 5.52.0 => 5.52.0
webpack-bundle-analyzer: 4.4.2 => 4.4.2
webpack-cli: 4.7.2 => 4.7.2
webpack-dev-middleware: 5.0.0 => 5.0.0
webpack-dev-server: 4.2.0 => 4.2.0
workbox-webpack-plugin: 6.2.4 => 6.2.4
Expected Behavior
Page load once and doesn't reload (once) until a change is made.
Actual Behavior
Page reloads infinitely in an endless loop. You open the site in the browser and the page starts reloading in a loop immediately when loaded.
For Bugs; How can we reproduce the behavior?
I believe this problem only occurs in large projects. We have a big monorepo with multiple products all running on the same domain and built in the same Webpack step.
I have built
webpack-dev-server
locally and narrowed it down to this single commit that introduced the issue: a6501e6When using the previous commit of
webpack-dev-server
in our project, the issue is not there. With this commit, the issue is there and we get a reload loop.I believe this is because the commit changed
heartbeatInterval
from 30 seconds to 1 second, and if the client isn't alive it terminates the client. In the browser logs for the reloads we can see a "Disconnected!" message and then it reloads. In our case, I'm thinking that sometimes things are too slow to start up within one second, andwebpack-dev-server
then disconnects, reloads, waits 1 second, disconnects... in a loop.I have tried modifying this timer locally, and both 20 seconds and 5 seconds were fine for us, and didn't cause any reload loop. I'm not sure of the reasoning for lower this heartbeat from 30 seconds to 1 second, but if it's okay to keep it high, I think high would make sense to not cause instability for others depending on computer speed etc.
Let me know if you need any more details! Thank you.
For Features; What is the motivation and/or use-case for the feature?
The text was updated successfully, but these errors were encountered: