-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[sockjs-client] fix exponential reconnect time #1616
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
Comments
@carlosgeos thanks for issue |
Should be fixed in v4 |
I don't see any related changes in the code, and it seems that v4 still keeps retrying indefinitely without any exponential backoff. |
@amakhrov Can you check you have a latest version? If you still have a problem, please provide example how we can reproduce it |
We're on 4.7.3 The exact scenario is webpack-dev-server terminating the socket, if it didn't receive the "pong" from the client as a part of heartbeat check. |
@amakhrov Maybe you can provide example? Also you can send a PR without tests (if you have solution), so I will look at code and try to search potential problem places |
Now as I think further about the use case, I understand why retries do not work properly. In this case a client socket successfully connects, but then the server terminates it (due to the lack of ping response). Every time a socket successfully connects, I'm not sure it's possible for the client socket to differentiate between the two cases, though |
Code
You can see the problem here:
https://github.com/webpack/webpack-dev-server/blob/v3.1.14/client-src/default/socket.js
Expected Behavior
An exponential increase in time between reconnects with the sockjs server.
Actual Behavior
As you can see in the code I linked, the method
onopen
resets theretries
variable to 0, so retries is always 0, andonclose
always tries to reconnect waiting the minimum time. Therefore the 'infinite logspam' solution doesn't work and people experience what is depicted in #1604Also, here (from #1604 as well):

How can we reproduce the behavior?
Make the sockjs server close the connection (for example because the client has a bad origin header), the client will try to reconnect forever without respecting the intended timeout.
It is obvious looking at the code anyway.
PR
I've already submitted a PR.
The text was updated successfully, but these errors were encountered: