Reduce WebSocket log noise - hide normal reconnection messages
Description
Recent Comments
## Code Review: Ticket #127 - WebSocket Log Noise Fix ✓ PASS ### Bug Normal WebSocket closures (`StatusNormalClosure`) were logged as ERROR, flooding terminal with: ``` [BRIDGE ERROR] WebSocket read error: ... StatusNormalClosure ... [BRIDGE] WebSocket disconnected. Reconnecting in 5s... ``` ### Root Cause All WebSocket disconnections logged identically, regardless of whether they were: - Normal closures (server-side disconnect, expected) - Actual errors (network failures, timeouts) ### Fix Applied **Changes in `agent-bridge.go`:** 1. **Added `disconnectionError` flag** (line 250): ```go disconnectionError := false ``` Tracks whether disconnection was due to error vs normal closure. 2. **Type assertion for CloseError** (lines 257-263): ```go if closeErr, ok := err.(*websocket.CloseError); ok && closeErr.StatusCode == websocket.StatusNormalClosure { disconnectionError = false // Silent reconnection } else { disconnectionError = true // Log actual error log.Printf("[BRIDGE ERROR] WebSocket read error: %v", err) } ``` - Uses proper Go type assertion with `ok` check - Compares `StatusCode` to `websocket.StatusNormalClosure` - Only logs actual errors 3. **Conditional reconnection message** (lines 296-298): ```go if disconnectionError { log.Printf("[BRIDGE] WebSocket disconnected. Reconnecting in %v...", backoff) } ``` - Silent for normal closures - Only shown for actual errors ### Acceptance Criteria Met - ✓ Normal closures not logged as ERROR - ✓ Automatic reconnection messages hidden for normal closures - ✓ Only actual errors logged to terminal - ✓ Quiet mode for successful reconnections ### Code Quality - Proper Go type assertion: `err.(*websocket.CloseError)` - Follows nhooyr.io/websocket library conventions - Clear variable naming and comments - No breaking changes to existing error handling - Minimal, targeted fix (16 lines added, 2 removed) ### No Issues Found Clean bug fix that reduces terminal noise while preserving error visibility. Ready to merge.
Ticket Stats
Comments
1 commentsAdd a Comment
No Subtasks Yet
Break down this ticket into smaller, manageable subtasks