Trying to fix multiple EventStream connections, one more time
This commit is contained in:
@@ -31,23 +31,20 @@ const setTimeout = (value) => {
|
||||
window.clearTimeout(timeout)
|
||||
}
|
||||
timeout = window.setTimeout(async () => {
|
||||
if (es) {
|
||||
es.close()
|
||||
}
|
||||
es?.close()
|
||||
es = null
|
||||
await startEventStream()
|
||||
}, currentIntervalCheck)
|
||||
}
|
||||
|
||||
const stopEventStream = () => {
|
||||
if (es) {
|
||||
es.close()
|
||||
}
|
||||
es?.close()
|
||||
es = null
|
||||
if (timeout) {
|
||||
window.clearTimeout(timeout)
|
||||
}
|
||||
timeout = null
|
||||
console.log('eventSource closed') // TODO For debug purposes. Remove later
|
||||
}
|
||||
|
||||
const setDispatch = (dispatchFunc) => {
|
||||
@@ -77,6 +74,8 @@ const startEventStream = async () => {
|
||||
newStream.addEventListener('keepAlive', eventHandler)
|
||||
newStream.onerror = (e) => {
|
||||
console.log('EventStream error', e)
|
||||
es?.close()
|
||||
es = null
|
||||
setTimeout(reconnectIntervalCheck)
|
||||
dispatch(serverDown())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user