Skip to content

fix: Back off activity watch reconnects on failure - #233

Merged
mattdjenkinson merged 2 commits into
mainfrom
fix/activity-watch-reconnect-backoff
Sep 15, 2026
Merged

mattdjenkinson merged 2 commits into
mainfrom
fix/activity-watch-reconnect-backoff

Conversation

@kevwilliams

@kevwilliams kevwilliams commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

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

  • A healthy connection streams normally with no added delay
  • A failing connection waits longer between each retry
  • Repeated failures stop automatic retries until streaming restarts

Related to datum-cloud/infra#5060
Related to datum-cloud/staff-portal#663

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
@mattdjenkinson
mattdjenkinson merged commit 917556e into main Sep 15, 2026
5 checks passed
@mattdjenkinson
mattdjenkinson deleted the fix/activity-watch-reconnect-backoff branch September 15, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants