Applied Backend Fixes
WebSocket Concurrency Error Fix:
- Location:
backend/main.py->ConnectionManager.broadcastandConnectionManager.broadcast_to_agents. - Change: Updated the iterator from
self.active_connections(andself.agent_connections) tolist(self.active_connections). - Reason: In an async environment, yielding execution via
awaitwhile iterating a list leaves the list open to modification (e.g., another coroutine closing the socket and removing it). Iterating over a copy prevents iteration issues like missing elements orRuntimeError.
- Location:
Detections History Memory Leak Fix:
- Location:
backend/main.py->_upsert_detection_sighting. - Change: Added
_trim_memory_list(detections_history, 500)immediately after appending a new record todetections_history. - Reason: Most history arrays in the project use
_trim_memory_listto enforce a maximum cap.detections_historywas appending arbitrarily, representing an unbounded memory leak if there's a constant influx of unique/unknown person detections over prolonged uptime.
- Location: