fix: retry transient IMAP aborts - #173
Conversation
pilipilisbot
left a comment
There was a problem hiding this comment.
Thanks for the PR. I checked the linked Sentry issue, the PR diff, CI status, and ran the changed test areas locally in a throwaway virtualenv.
The IMAP retry itself looks directionally right: the retry is bounded to one reconnect, the durable last_uid cursor is re-read for the replay, and duplicate notification insertion remains protected by message_id uniqueness. The focused reader/queue subset passed locally:
/tmp/gab-pr173-venv/bin/python -m pytest -q tests/test_reader.py tests/test_reader_run.py tests/test_queue.py -> 25 passed
I need changes before merge because the PR currently includes monitor/queue changes that are outside the stated IMAP-abort scope, and the monitor test suite is not stable under the current published release state. This command failed locally:
/tmp/gab-pr173-venv/bin/python -m pytest -q tests/test_reader.py tests/test_reader_run.py tests/test_queue.py tests/test_monitor.py
Failures were in existing monitor assertions such as test_monitor_ok_on_empty_initialized_db, where _latest_github_release() reached GitHub, found v0.58.2, and produced a release alert even though the test expected report.ok is True. Since this PR touches monitor.py/tests/test_monitor.py, please either isolate/mock the release lookup in the affected monitor tests or separate the monitor/queue work into the PR where that behavior is intended and keep this PR to the IMAP retry.
Once that is cleaned up, the IMAP change itself should be straightforward to approve.
Co-authored-by: pilipilisbot <265267145+pilipilisbot@users.noreply.github.com>
428972e to
73002af
Compare
|
Addressed the requested scope cleanup in The branch had inherited three older commits, which made unrelated
Verification: |
pilipilisbot
left a comment
There was a problem hiding this comment.
Approved. The branch now contains only the intended IMAP reader retry change plus focused tests, so the earlier scope blocker is resolved.
I checked the current PR context, previous review, changed-file list, diff, and CI status. Locally on the PR head 73002af, I ran:
PYTHONPATH=src /tmp/gab-pr173-venv/bin/python -m pytest -q tests/test_reader.py tests/test_reader_run.py tests/test_queue.py-> 38 passedPYTHONPATH=src /tmp/gab-pr173-venv/bin/python -m pytest -q-> 343 passed, 1 existing warninggit diff --check-> clean
The retry is bounded to one reconnect, preserves the second abort as the failure signal, and replays through the existing durable UID/message-id safeguards, which is the right shape for transient Gmail socket aborts.
|
Post-merge follow-up: no further repository changes needed for this event.
|
Summary
Why
Gmail can transiently close an IMAP connection during
SELECT. The readercurrently exits immediately, delaying notification ingestion until the next
timer run and reporting an avoidable Sentry error.
The retry is bounded to one reconnect. Replaying the pass is safe because
last_uidadvances after each handled message andmessage_idis unique inthe durable queue.
Original report: gisce#23
Tests
PYTHONPATH=src /home/openclaw/.pyenv/versions/erp3/bin/python -m pytest -q tests/test_reader.py— 2 passed73002afRequested by: automated Sentry alert in gisce#23 (no human requester)