fix(ned): surgical daemon stability and validation improvements #98

Merged
clanker merged 5 commits from pr/ned-stability-fixes into main 2026-11-25 07:31:51 +00:00
Member

Applies 5 backwards-compatible stability fixes to NED without changing wire protocols or client behavior:

  1. Serialize concurrent sync.run_sync() calls (ned/sync.py): Add a non-blocking single-flight _sync_lock so overlapping scheduler/manual/startup syncs cannot race mbsync on .mbsyncstate and Maildirs.
  2. Preserve tag:trash on partial expunge failures (ned/actions.py): Track failed/skipped files in expunge_trash() so -trash is not stripped globally when any file fails to unlink/rename or lives outside Trash.
  3. Validate HTTP integer query params and JSON object bodies (ned/handler.py): Return clean HTTP 400/413 JSON errors on invalid limit/offset/part_id, malformed JSON, or non-object JSON payloads.
  4. Kill msmtp on timeout and close probe sockets (ned/service.py, ned/daemon.py, ned/main.py): Terminate and reap timed-out sendmail subprocesses, and use context-managed sockets for Unix socket liveness probes.
  5. Handle SSL non-blocking exceptions in SSE (ned/client.py): Retry on ssl.SSLWantReadError / ssl.SSLWantWriteError, drain raw_sock.pending(), and unify SSE line parsing.

Verification

  • QT_QPA_PLATFORM=offscreen ~/.local/share/pipx/venvs/lazarus-mail/bin/python -m pytest -p no:cacheprovider → 573 passed
  • uvx --from mypy mypy --config-file mypy.ini ned → Success: no issues found in 26 source files
  • uvx pyflakes ned/sync.py ned/actions.py ned/handler.py ned/service.py ned/daemon.py ned/main.py ned/client.py → clean
Applies 5 backwards-compatible stability fixes to NED without changing wire protocols or client behavior: 1. **Serialize concurrent `sync.run_sync()` calls** (`ned/sync.py`): Add a non-blocking single-flight `_sync_lock` so overlapping scheduler/manual/startup syncs cannot race `mbsync` on `.mbsyncstate` and Maildirs. 2. **Preserve `tag:trash` on partial expunge failures** (`ned/actions.py`): Track failed/skipped files in `expunge_trash()` so `-trash` is not stripped globally when any file fails to unlink/rename or lives outside Trash. 3. **Validate HTTP integer query params and JSON object bodies** (`ned/handler.py`): Return clean HTTP 400/413 JSON errors on invalid `limit`/`offset`/`part_id`, malformed JSON, or non-object JSON payloads. 4. **Kill `msmtp` on timeout and close probe sockets** (`ned/service.py`, `ned/daemon.py`, `ned/main.py`): Terminate and reap timed-out sendmail subprocesses, and use context-managed sockets for Unix socket liveness probes. 5. **Handle SSL non-blocking exceptions in SSE** (`ned/client.py`): Retry on `ssl.SSLWantReadError` / `ssl.SSLWantWriteError`, drain `raw_sock.pending()`, and unify SSE line parsing. ### Verification - `QT_QPA_PLATFORM=offscreen ~/.local/share/pipx/venvs/lazarus-mail/bin/python -m pytest -p no:cacheprovider` → **573 passed** - `uvx --from mypy mypy --config-file mypy.ini ned` → **Success: no issues found in 26 source files** - `uvx pyflakes ned/sync.py ned/actions.py ned/handler.py ned/service.py ned/daemon.py ned/main.py ned/client.py` → **clean**
clanker deleted branch pr/ned-stability-fixes 2026-11-25 07:31:51 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Home/lazarus!98
No description provided.