cloudflare / cloudflare/moltworker
Feature Request: Auto-reconnect WebSocket on connection loss
- Dominant language
- TypeScript
- Stars
- 10k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
The Control UI WebSocket connection occasionally drops and doesn't automatically reconnect. Users have to manually refresh the page to restore the connection. This can be frustrating when the connection drops mid-conversation.
## Current Behavior
- WebSocket disconnects (network issues, idle timeout, etc.)
- UI shows disconnected state
- User must manually refresh the page
## Desired Behavior
- Detect WebSocket disconnection
- Automatically attempt to reconnect with exponential backoff
- Show reconnecting status to user
- Resume session seamlessly without page reload
## Suggested Implementation
Add reconnection logic to `BrowserWebSocketTransport`:
```javascript
// On close, attempt reconnect
ws.addEventListener("close", () => {
setTimeout(() => reconnect(), reconnectInterval);
reconnectInterval = Math.min(reconnectInterval * 2, 30000);
});
Contributor guide
Assessment
This issue has not been assessed yet.