Description of the Bug
In frontend/src/components/chat/ChatPanel.tsx, the WebSocket connection has a timeout of only 800ms:
const wsTimeout = setTimeout(() => {
// WebSocket didn't connect fast enough, fall back to SSE
setIsWsConnected(false);
startSSE();
}, 800);
An 800ms timeout is too aggressive for WebSocket connections. WebSocket connections require:
- DNS resolution (can take 100-500ms on slow networks)
- TCP handshake
- HTTP upgrade handshake
- Server-side processing time
On slow networks, cold-start servers, or under load, this can easily exceed 800ms, causing the application to unnecessarily fall back to SSE streaming. This means users lose the benefits of real-time WebSocket streaming (lower latency, full-duplex) even though WebSocket would have worked fine given an extra second or two.
Steps to Reproduce
- Connect to the application over a slow network (e.g., mobile 3G, throttled connection)
- Start a chat session and send a message
- The WebSocket connection attempt times out at 800ms
- The client falls back to SSE, losing real-time streaming benefits
- WebSocket would have succeeded with a longer timeout
Expected Behavior
The timeout should be increased to at least 5000ms (5 seconds) to account for network and server startup latency. A retry mechanism should also be considered before falling back.
Affected File
frontend/src/components/chat/ChatPanel.tsx (line ~283)
Suggested Fix
Increase the timeout:
const WS_TIMEOUT_MS = 5000; // 5 seconds instead of 800ms
Consider adding a single retry attempt before falling back to SSE.
GSSoC '26
Description of the Bug
In
frontend/src/components/chat/ChatPanel.tsx, the WebSocket connection has a timeout of only 800ms:An 800ms timeout is too aggressive for WebSocket connections. WebSocket connections require:
On slow networks, cold-start servers, or under load, this can easily exceed 800ms, causing the application to unnecessarily fall back to SSE streaming. This means users lose the benefits of real-time WebSocket streaming (lower latency, full-duplex) even though WebSocket would have worked fine given an extra second or two.
Steps to Reproduce
Expected Behavior
The timeout should be increased to at least 5000ms (5 seconds) to account for network and server startup latency. A retry mechanism should also be considered before falling back.
Affected File
frontend/src/components/chat/ChatPanel.tsx(line ~283)Suggested Fix
Increase the timeout:
Consider adding a single retry attempt before falling back to SSE.
GSSoC '26