fix: Back off activity watch reconnects on failure - #233
Merged
Merged
Conversation
useActivityFeed reopened a dropped watch stream immediately, with no delay and no limit, whenever enableStreaming was on. Against an upstream that keeps aborting the connection, this reconnects in a tight loop with a single browser tab driving continuous request volume against the server. This showed up as staff-portal's proxy getting OOMKilled: one Firefox tab holding the activity page open reconnected roughly 2.5 times a minute against a watch that kept erroring, and each attempt cost the proxy's buffering client memory it only released on process death. Fixing the proxy (datum-cloud/staff-portal#663) removes the buffering, but a client that reopens a failing connection with zero backoff is still poor behavior against any upstream, buffering or not. Reconnects now back off exponentially (1s, 2s, 4s, ... capped at 30s) and give up automatically after 8 consecutive failures, leaving watchError set until the caller (or user) explicitly calls startStreaming() again. The counter resets on any real event, including BOOKMARK keep-alives, so a healthy connection isn't penalized for a past failure. Related to datum-cloud/infra#5060
ecv
approved these changes
Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
A dropped watch connection reopened instantly and without limit whenever streaming was on.
One browser tab left open against a failing connection could reconnect several times a minute, indefinitely.
That pattern helped drive the memory leak behind infra#5060, alongside a separate proxy bug fixed in staff-portal#663.
Reconnects now wait longer after each failure and stop retrying after repeated failures, resuming only once streaming restarts.
Test plan
Related to datum-cloud/infra#5060
Related to datum-cloud/staff-portal#663