mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-23 15:54:22 +00: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()
|
lastHeartbeat = Date.now()
|
||||||
|
|
||||||
reconnectIfInactive = () ->
|
reconnectIfInactive = () ->
|
||||||
timeSinceLastHeartBeat = Date.now() - lastHeartbeat
|
timeSinceLastHeartbeat = Date.now() - lastHeartbeat
|
||||||
if timeSinceLastHeartBeat > reconnectAfter
|
if timeSinceLastHeartbeat > reconnectAfter
|
||||||
console.warn "No heartbeat for #{timeSinceLastHeartBeat}ms, reconnecting"
|
console.warn "No heartbeat for #{timeSinceLastHeartbeat}ms, reconnecting"
|
||||||
sub.connection_gone("no heartbeat for #{timeSinceLastHeartBeat}ms")
|
sub.connection_gone("no heartbeat for #{timeSinceLastHeartbeat}ms")
|
||||||
|
# Reset timer after triggering a reconnect to avoid potential cascading failure.
|
||||||
|
lastHeartbeat = Date.now()
|
||||||
|
|
||||||
setInterval () ->
|
setInterval () ->
|
||||||
pub.publish heartbeatChannel, "PING"
|
pub.publish heartbeatChannel, "PING"
|
||||||
|
|
Loading…
Reference in a new issue