Revert "fix: replace fixed 15s WebSocket reconnect with exponential backoff + jitter"#5715
Revert "fix: replace fixed 15s WebSocket reconnect with exponential backoff + jitter"#5715
Conversation
…ackoff +…" This reverts commit fa95dcf.
Greptile SummaryThis PR reverts #5617, which replaced the fixed 15-second WebSocket reconnection timer with exponential backoff + jitter. The revert restores the original
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant WS as WebSocket
participant CP as CaptureProvider
participant Timer as Timer.periodic(15s)
WS->>CP: onClosed() / onError()
CP->>Timer: _startKeepAliveServices()
Note over Timer: Cancel existing timer, start new 15s periodic
loop Every 15 seconds
Timer->>CP: Timer fires
CP->>CP: Check rate limit (1/15s)
CP->>CP: Check socket connected?
alt Socket connected or device not ready
CP->>Timer: Cancel timer
else User not signed in
CP->>Timer: Cancel timer
else Device available
CP->>WS: _initiateWebsocket(codec, source)
alt Socket created successfully
WS->>CP: onConnected()
CP->>Timer: Next tick cancels (connected)
else Socket creation failed
CP->>Timer: _startKeepAliveServices() (restart timer)
end
end
end
Last reviewed commit: 8ed4791 |
| _keepAliveTimer = Timer.periodic(const Duration(seconds: 15), (t) async { | ||
| Logger.debug("[Provider] keep alive"); | ||
| // rate 1/15s | ||
| if (_keepAliveLastExecutedAt != null && | ||
| DateTime.now().subtract(const Duration(seconds: 15)).isBefore(_keepAliveLastExecutedAt!)) { |
There was a problem hiding this comment.
Redundant rate-limit check with fixed timer
The rate-limiting guard at lines 1330-1331 checks whether 15 seconds have elapsed since the last execution, but the Timer.periodic already fires at 15-second intervals. This makes the check effectively a no-op under normal conditions. It's not harmful, but it's dead code that could be removed for clarity — or if the intent is to guard against overlapping async callbacks, consider using a simple boolean lock instead.
Reverts #5617