[enh] don't repeatedly alert about a failed state

This commit is contained in:
2020-05-08 11:15:09 +02:00
parent de43be347f
commit 8ecca50268
2 changed files with 13 additions and 1 deletions

View File

@@ -47,7 +47,10 @@ export function watcherLoop(
}
// Wait before reconnecting
const waitingDelay = reconnectionDelays[Math.min(reconnectionDelays.length - 1, i)]
await onDisconnection(waitingDelay, watcher.error)
if (watcher.stateChanged) {
// Notify only if state changed since
await onDisconnection(waitingDelay, watcher.error)
}
await new Promise(resolve => setTimeout(resolve, waitingDelay))
i++
}