Skip to content

[sockjs-client] fix exponential reconnect time  #1616

Closed
@carlosgeos

Description

@carlosgeos
  • Operating System: Debian
  • Node Version: v11.6.0
  • NPM Version: 6.5.0
  • webpack Version: 4.28.3
  • webpack-dev-server Version: 3.1.14
  • This is a bug

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 the retries variable to 0, so retries is always 0, and onclose always tries to reconnect waiting the minimum time. Therefore the 'infinite logspam' solution doesn't work and people experience what is depicted in #1604

Also, here (from #1604 as well):
50633098-6354a900-0f4a-11e9-95ba-22cbbc569438

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions