server: guard against None snapshots crashing the accept loop

If extract_all() returns None (Dashboard init failure), appending it to
store["records"] would cause _accept_loop to crash with AttributeError on
the next client connection.  Since only OSError was caught, the thread
died permanently — no further clients could join push_clients, so live
broadcasts reached nobody.

- collect.py: skip None snapshots instead of appending them
- network.py: filter None records in _accept_loop; catch all exceptions
  during history send (not just OSError) so the thread survives
- storage_helpers.py: filter None records when loading from disk

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 00:42:31 +02:00
co-authored by Claude Sonnet 4.6
parent dfd5ef7f56
commit b75c4fe411
3 changed files with 17 additions and 8 deletions
+2 -2
View File
@@ -53,11 +53,11 @@ def load_last_24h_records(logs_dir: Path, vin: str) -> list:
try:
data = json.loads(path.read_text())
if isinstance(data, dict) and "records" in data:
kept = [r for r in data["records"] if r.get("ts", "") >= cutoff_str]
kept = [r for r in data["records"] if r is not None and r.get("ts", "") >= cutoff_str]
records.extend(kept)
log.debug("Loaded %d/%d records from %s", len(kept), len(data["records"]), path.name)
except (json.JSONDecodeError, OSError):
log.warning("Could not load %s", path)
records.sort(key=lambda r: r.get("ts", ""))
records.sort(key=lambda r: r.get("ts", "") if r is not None else "")
return records