Unverified Commit 48b9c1a2 authored by Benjie's avatar Benjie Committed by GitHub

Prevent `handleDisconnect` being called twice (#46959)

### Fixing a bug

When a timeout occurs the `handleDisconnect` can be called twice on my
machine (Chrome 110.0.5481.178). Once by the timeout code, and once by
the `onerror` handler, possibly triggered by the `source.close()` call.
This leads to every timeout triggering twice as many clients, which
quickly explodes to websocket reconnections spamming the network tab of
devtools. This trivial fix resolves the issue.
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent e7cbf4b5
......@@ -51,6 +51,7 @@ export function connectHMR(options: {
let timer: NodeJS.Timeout
function handleDisconnect() {
clearInterval(timer)
source.onerror = null
source.close()
setTimeout(init, options.timeout)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment