Skip to content

Commit

Permalink
bug: CORE-9928 - Prevent possible bomb in startkeepalive
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac Bowhay committed Nov 4, 2024
1 parent f5606af commit 3ec6a9c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ class Agent {
if (!this.connected) return

const ws = this.ws
// clean up any existing keepalive timers before registering new ones. This prevents a bug that occurs if _startKeepAlive() is invoked multiple times.
// _startKeepAlive() invoked once -> this._keepAliveTimeout is registered in state with the pong listener relying on that state to clear it.
// _startKeepAlive() invoked second -> overwrites this._keepAliveTimeout.
// Now, when original pong listener goes to clear timer based on this._keepAliveTimeout state, it has lost the reference to the first timer which results in it blowing up at 10 seconds
this._stopKeepAlive();

ws.ping()

Expand Down

0 comments on commit 3ec6a9c

Please sign in to comment.