diff --git a/priv/server/live-reload.js b/priv/server/live-reload.js index d35b9ec..89f9f15 100644 --- a/priv/server/live-reload.js +++ b/priv/server/live-reload.js @@ -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); }; }