Skip to content

fix: add retry/backoff to inbound email listener for transient failures#234

Draft
bukinoshita wants to merge 3 commits intomainfrom
fix/listen-retry-transient-failures-5d01
Draft

fix: add retry/backoff to inbound email listener for transient failures#234
bukinoshita wants to merge 3 commits intomainfrom
fix/listen-retry-transient-failures-5d01

Conversation

@bukinoshita
Copy link
Copy Markdown
Member

@bukinoshita bukinoshita commented Apr 9, 2026

Summary by cubic

Adds retry/backoff to the inbound email listener to handle transient 429 and network errors so it keeps running without dropping emails. Fixes Linear BU-637 by using shared retry logic and counting failures only after retries are exhausted.

  • Bug Fixes
    • Added retryPoll for poll loops: retries rate_limit_exceeded up to 3 times (uses Retry-After or 1s/2s/4s), retries thrown network errors, and returns a simple result object.
    • Updated emails receiving listen to use retryPoll for initial connect and polling; only increments consecutiveErrors after retries; exits after 5 real failures; preserves order with [...newEmails].reverse().
    • Added tests for retryPoll (success, rate limit, retry-after, thrown errors, exhaustion) and updated listen tests to it().

Written for commit 1d1d104. Summary will update on new commits.

@bukinoshita
Copy link
Copy Markdown
Member Author

@cursor can you fix conflicts

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 13, 2026

The PR description was updated by cubic (automated). No human edits to preserve beyond that. The conflicts are resolved and the PR is up to date.

Conflicts resolved. I rebased the branch onto the latest main, which had added safeTerminalText to listen.ts. The resolution keeps both changes: the new retryPoll retry/backoff logic from this PR and the safeTerminalText sanitization from main. All 798 tests pass, lint and typecheck are clean.

Open in Web Open in Cursor 

cursoragent and others added 3 commits April 13, 2026 23:50
Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
…ience

Wrap all SDK calls in retryPoll() which retries rate_limit_exceeded errors
using Retry-After headers and exponential backoff, and retries transient
network errors. Only increment consecutiveErrors after retries are
exhausted, preventing premature exits on temporary API/network issues.

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
@cursor cursor bot force-pushed the fix/listen-retry-transient-failures-5d01 branch from 1d1d104 to 09e06a3 Compare April 13, 2026 23:52
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.

2 participants