brunch / auto-reload-brunch

Adds automatic browser reloading support to brunch.
88 stars 30 forks source link

Fixes Multi-Socket Reload Bug #82

Closed Anaphase closed 7 years ago

Anaphase commented 7 years ago

The socket close event handler appears to have a bug in it. As far as I know, the only acceptable first parameter to Array::splice is a Number (as opposed to an object as seen in line 65 of index.js.)

Specifying an object as the first parameter appears to always splice the first element off. This pull request fixes this issue by using Array::indexOf to look up the index of the socket first.

Some steps to illustrate this bug:

  1. Start your brunch server.
  2. Load up the page in Chrome.
  3. Load up the page in Firefox.
  4. Make a change and see that both browsers refresh.
  5. Close Firefox. This will cause Chrome's socket to to be popped off of the conns array instead of Firefox's.
  6. Make a change and see that Chrome is no longer responding.