mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Reset heartbeat timer after triggering a reconnect
This commit is contained in:
parent
b67b49564d
commit
db3537a8eb
1 changed files with 6 additions and 4 deletions
|
@ -39,10 +39,12 @@ module.exports = RedisSharelatex =
|
|||
lastHeartbeat = Date.now()
|
||||
|
||||
reconnectIfInactive = () ->
|
||||
timeSinceLastHeartBeat = Date.now() - lastHeartbeat
|
||||
if timeSinceLastHeartBeat > reconnectAfter
|
||||
console.warn "No heartbeat for #{timeSinceLastHeartBeat}ms, reconnecting"
|
||||
sub.connection_gone("no heartbeat for #{timeSinceLastHeartBeat}ms")
|
||||
timeSinceLastHeartbeat = Date.now() - lastHeartbeat
|
||||
if timeSinceLastHeartbeat > reconnectAfter
|
||||
console.warn "No heartbeat for #{timeSinceLastHeartbeat}ms, reconnecting"
|
||||
sub.connection_gone("no heartbeat for #{timeSinceLastHeartbeat}ms")
|
||||
# Reset timer after triggering a reconnect to avoid potential cascading failure.
|
||||
lastHeartbeat = Date.now()
|
||||
|
||||
setInterval () ->
|
||||
pub.publish heartbeatChannel, "PING"
|
||||
|
|
Loading…
Reference in a new issue