Skip to content

fix: retry transient IMAP aborts - #173

Merged
ecarreras merged 1 commit into
pilipilisbot:mainfrom
gisce:fix/imap-abort-retry
Aug 4, 2026
Merged

fix: retry transient IMAP aborts#173
ecarreras merged 1 commit into
pilipilisbot:mainfrom
gisce:fix/imap-abort-retry

Conversation

@giscebot

@giscebot giscebot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • reconnect once when an IMAP command aborts because the server closed the socket
  • retry the complete reader pass using the durable UID cursor
  • preserve the failure signal when the retry also aborts

Why

Gmail can transiently close an IMAP connection during SELECT. The reader
currently 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_uid advances after each handled message and message_id is unique in
the durable queue.

Original report: gisce#23

Tests

  • PYTHONPATH=src /home/openclaw/.pyenv/versions/erp3/bin/python -m pytest -q tests/test_reader.py — 2 passed
  • GitHub Actions Python 3.11/3.12 and dashboard checks — passed for commit 73002af

Requested by: automated Sentry alert in gisce#23 (no human requester)

@pilipilisbot pilipilisbot left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@giscebot
giscebot force-pushed the fix/imap-abort-retry branch from 428972e to 73002af Compare August 3, 2026 15:49
@giscebot

giscebot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the requested scope cleanup in 73002af.

The branch had inherited three older commits, which made unrelated monitor.py, queue.py, and corresponding test changes appear in this PR. I rebuilt the branch on the current main and retained only the IMAP retry commit. The PR now changes only:

  • src/github_agent_bridge/reader.py
  • tests/test_reader.py

Verification: tests/test_reader.py passes (2 tests), git diff --check passes, and the Python 3.11, Python 3.12, and dashboard GitHub Actions checks all pass on the rewritten head.

@ecarreras
ecarreras requested a review from pilipilisbot August 4, 2026 07:52

@pilipilisbot pilipilisbot left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 passed
  • PYTHONPATH=src /tmp/gab-pr173-venv/bin/python -m pytest -q -> 343 passed, 1 existing warning
  • git 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.

@ecarreras
ecarreras merged commit 54271d6 into pilipilisbot:main Aug 4, 2026
3 checks passed
@pilipilisbot

Copy link
Copy Markdown
Owner

Post-merge follow-up: no further repository changes needed for this event.

  • PR fix: retry transient IMAP aborts #173 was merged by @ecarreras as merge commit 54271d609c3619641086c619c4040394be820df6.
  • Final reviewed head was 73002af, limited to reader.py and tests/test_reader.py for the transient IMAP abort retry.
  • Required checks were green (dashboard, pytest (3.11), pytest (3.12)), and there are no open review threads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants