fix: replace heartbeat with keep alive #236
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So initially the SDK connection stability was implemented to deal with browser issues. Things like unfocusing the tab and detecting disconnect immediately when you refocus after hibernation etc. This was done with an empty ping/pong message and detecting lack of pong detection.
Now the users or on the edge there are other challenges. Things like hibernated processes like Vercel Fluid Compute and CloudFlare Workflows. In this case it is important that heartbeats has payload and they need to be more aggressive.
Instead of having two mechanisms for "keep alive" (one at SDK interface level and one internal heartbeat for the websocket) we now only rely on the explicit
keepActiveWhileConnectedlogic. This sends an actual payload every 10 seconds to Pitcher. Previously this was by defaultfalse, but is now defaulttrue.Additionally I noticed the SDK subscribes to data like git status and metrics from Pitcher. Data that we are not exposing in any way and just adds unnecessary processing on Pitcher.