Skip to content

Commit

Permalink
🐛 Fix bug where socket would try to reconnect far too many times.
Browse files Browse the repository at this point in the history
  • Loading branch information
hayleigh-dot-dev committed Jun 14, 2024
1 parent ffb31a5 commit 8a9d963
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions priv/server/live-reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ function connect() {
// refresh.
socket.onclose = () => {
socket = null;
if (!timeout) timeout = setTimeout(() => connect(), 5000);

if (timeout) clearTimeout(timeout);
if (!socket) timeout = setTimeout(() => connect(), 5000);
};

socket.onerror = () => {
socket = null;
if (!timeout) timeout = setTimeout(() => connect(), 5000);

if (timeout) clearTimeout(timeout);
if (!socket) timeout = setTimeout(() => connect(), 5000);
};
}

Expand Down

0 comments on commit 8a9d963

Please sign in to comment.