Skip to content

fix: reset SSE inactivity timeout on each broadcast#177

Open
jakebromberg wants to merge 2 commits intomainfrom
fix/33-sse-activity-timeout
Open

fix: reset SSE inactivity timeout on each broadcast#177
jakebromberg wants to merge 2 commits intomainfrom
fix/33-sse-activity-timeout

Conversation

@jakebromberg
Copy link
Member

Summary

  • Bug: The 5-minute SSE inactivity timeout in ServerEventsManager was set once at client registration and never reset, causing active clients receiving broadcasts/dispatches to be disconnected after exactly 5 minutes regardless of activity.
  • Fix: Store timeout handles per client in a clientTimeouts map. Added a resetTimeout() method that clears and restarts the timer, called on every successful broadcast and dispatch write. Timeouts are also cleaned up in unsubAll and the close handler.
  • Tests: Added 4 unit tests covering idle disconnect, timeout reset on broadcast, timeout reset on dispatch, and eventual disconnect after a reset window elapses.

Fixes #33

Test plan

  • npm run test:unit -- tests/unit/utils/serverEvents.test.ts — all 4 tests pass
  • Manual: connect an SSE client, leave idle > 5 min → verify disconnect
  • Manual: connect an SSE client, send broadcasts within 5-min windows → verify it stays connected

Made with Cursor

The 5-minute timeout was set once at registration and never reset,
disconnecting actively-used SSE clients.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jakebromberg jakebromberg force-pushed the fix/33-sse-activity-timeout branch from d9bd557 to 01698fd Compare February 27, 2026 05:55
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.

2 participants