fix: SSE reconnect with exponential backoff and terminal state #7

Merged
forbes merged 2 commits from fix/sse-reconnect into main 2026-02-08 22:23:24 +00:00
Owner

The SSE live connection would show Reconnecting... indefinitely with no diagnostics. This fixes the retry behavior and adds visibility.

Changes

SiloEventListener

  • Exponential backoff: 1s, 2s, 4s, 8s, 16s, 32s, 60s (capped) instead of fixed 5s/30s delays
  • Max retries: Stops after 10 attempts (configurable via _MAX_RETRIES)
  • Terminal state: Emits "gave_up" status when max retries exhausted (thread exits)
  • Error forwarding: Captures exception messages and passes them through the signal
  • Expanded signal: connection_status(str, int, str) now carries (status, retry_count, error_message)

SiloAuthDockWidget._on_sse_status

  • Shows retry progress: Reconnecting (3/10)...
  • Shows terminal state: Disconnected in red when gave up
  • Logs each attempt to FreeCAD console (PrintWarning for retries, PrintError for gave_up, PrintMessage for connected)
  • Sets tooltip on status label with last error message

Acceptance criteria

  • Backoff implemented with configurable max retries
  • Terminal "Disconnected" state reachable
  • FreeCAD console receives structured log per reconnect attempt
  • Graceful behavior when server has no live endpoint (404 -> "unsupported", stops immediately)

Closes #2

The SSE live connection would show `Reconnecting...` indefinitely with no diagnostics. This fixes the retry behavior and adds visibility. ## Changes ### SiloEventListener - **Exponential backoff**: 1s, 2s, 4s, 8s, 16s, 32s, 60s (capped) instead of fixed 5s/30s delays - **Max retries**: Stops after 10 attempts (configurable via `_MAX_RETRIES`) - **Terminal state**: Emits `"gave_up"` status when max retries exhausted (thread exits) - **Error forwarding**: Captures exception messages and passes them through the signal - **Expanded signal**: `connection_status(str, int, str)` now carries `(status, retry_count, error_message)` ### SiloAuthDockWidget._on_sse_status - Shows retry progress: `Reconnecting (3/10)...` - Shows terminal state: `Disconnected` in red when gave up - Logs each attempt to FreeCAD console (`PrintWarning` for retries, `PrintError` for gave_up, `PrintMessage` for connected) - Sets tooltip on status label with last error message ## Acceptance criteria - [x] Backoff implemented with configurable max retries - [x] Terminal "Disconnected" state reachable - [x] FreeCAD console receives structured log per reconnect attempt - [x] Graceful behavior when server has no live endpoint (404 -> "unsupported", stops immediately) Closes #2
forbes added 1 commit 2026-02-08 21:36:20 +00:00
Replace the infinite fixed-delay retry loop with exponential backoff
(1s, 2s, 4s, ... capped at 60s) and a max retry limit of 10.

Changes to SiloEventListener:
- Expand connection_status signal to (status, retry_count, error_message)
- Add exponential backoff: min(BASE_DELAY * 2^retries, MAX_DELAY)
- Add terminal "gave_up" state after MAX_RETRIES exhausted
- Capture and forward error messages from failed connection attempts

Changes to SiloAuthDockWidget._on_sse_status:
- Show retry count: "Reconnecting (3/10)..."
- Show "Disconnected" (red) on gave_up state
- Log each attempt to FreeCAD console (PrintWarning/PrintError)
- Set tooltip with last error message on the status label

Closes #2
forbes force-pushed fix/sse-reconnect from 966bc6d2bf to c8e6317bae 2026-02-08 22:16:22 +00:00 Compare
forbes force-pushed fix/sse-reconnect from c8e6317bae to e5126c913d 2026-02-08 22:23:01 +00:00 Compare
forbes added 1 commit 2026-02-08 22:23:19 +00:00
forbes merged commit 66b2baf510 into main 2026-02-08 22:23:24 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/silo-mod#7