AOSSIE-Org / AOSSIE-Org/DebateAI
Issue: WebSocket error handling is brittle and silently failing in useDebateWS
- 主要言語
- TypeScript
- スター
- 84
- フォーク
- 198
- 平均マージ
- 2日 19時間
- マージ済み PR(30日)
- 30
説明
### Problem
The WebSocket message handler in `frontend/src/hooks/useDebateWS.ts` had brittle error handling and previously contained empty `catch` blocks, which could silently swallow failures. This made debugging difficult and degraded user experience during connectivity issues.
Beyond the empty catch block, the existing implementation also had several reliability gaps, including:
* Silent failure modes during message parsing
* Potential console spamming on repeated failures
* Unclear reconnection behavior
* No distinction between normal vs abnormal WebSocket closure
* Risky cleanup logic on component unmount
* No protection against malformed or empty messages
---
### Expected Behavior
WebSocket failures should:
* Be clearly logged with meaningful context
* Avoid flooding logs or UI with repeated errors
* Attempt reconnection with controlled backoff
* Treat normal WebSocket closure (code 1000) as non-error
* Clean up safely when the component unmounts
* Gracefully handle malformed or empty messages
---
### Proposed Fix
Refactor **`useDebateWS.ts`** to include:
* Centralized `handleError` with throttling
* Exponential backoff retry logic with a maximum cap
* Clear handling of normal vs abnormal closures
* Defensive message parsing (reject empty messages)
* Safer WebSocket cleanup using `try/finally`
* Reset of error state on successful messages
* Automatic reconnection attempts on failure
---
### File Affected
* `frontend/src/hooks/useDebateWS.ts`
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。