Skip to content

feat(dashboard): reconnect activity SSE with backoff and backfill missed events - #275

Closed
vreabernardo wants to merge 2 commits into
Adamantine-guild:mainfrom
vreabernardo:feat/activity-sse-reconnect
Closed

feat(dashboard): reconnect activity SSE with backoff and backfill missed events#275
vreabernardo wants to merge 2 commits into
Adamantine-guild:mainfrom
vreabernardo:feat/activity-sse-reconnect

Conversation

@vreabernardo

Copy link
Copy Markdown
Contributor

Closes #258

Stacked on #273 (main does not build at HEAD; this branches from the repaired tree). Happy to rebase once #273 merges.

Before this, a dropped SSE connection meant the feed silently fell back to the polling interval and anything published during the outage only showed up on the next poll. Now:

  • The client retries the stream with exponential backoff and jitter (1s base, doubling, capped at 30s). Polling still takes over, but only after 5 consecutive failed attempts, and it still handles the EventSource-unavailable case immediately. NEXT_PUBLIC_ACTIVITY_REFRESH_MS=0 manual-only mode is untouched.
  • Activity frames carry an id line, so native EventSource tracks lastEventId. The manual reconnect passes it along as ?lastEventId= and the stream route replays stored events published since that cursor (snapshot taken before subscribing, so nothing published in between is missed). Unknown cursor replays nothing, the REST backfill covers that.
  • After a reconnect the feed hook backfills through the activity API with from=, sort=oldest before live delivery resumes. The from filter is inclusive and the hook dedupes by event id, so overlap with the server replay is harmless.

Tests: the three client-connector tests that asserted immediate fallback now cover the reconnect contract (backoff instead of a tight retry loop, cursor on the reconnect URL, exhaustion into polling after N attempts), plus new coverage for the server replay and getEventsAfterCursor. Ran the full dashboard suite (556 passed, 0 failed, tsx --test across test/**) and eslint on the touched files. tsc reports only the pre-existing baseUrl deprecation in tsconfig.json.

vreabernardo added 2 commits July 24, 2026 00:40
…sed events

On stream drop the client now retries with exponential backoff and jitter
(1s base, 30s cap) instead of falling straight through to polling, which
still takes over after 5 consecutive failures or when EventSource is
unavailable. Frames carry an id line so EventSource tracks lastEventId;
manual reconnects pass it as ?lastEventId= and the stream route replays
stored events published since that cursor. After a reconnect the feed
hook backfills through the activity API with from=<last seen timestamp>
before resuming live delivery. Polling fallback and
NEXT_PUBLIC_ACTIVITY_REFRESH_MS=0 manual-only behavior are unchanged.

Closes Adamantine-guild#258
@vreabernardo

Copy link
Copy Markdown
Contributor Author

Withdrawing this contribution. Thanks for your time.

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.

Add reconnect-with-backoff and missed-event recovery to the Activity SSE stream

1 participant