Repository navigation
fix(import): back off on refused IMAP connections instead of shrinking the batch - #317
Merged
Merged
Conversation
…g the batch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LRRzcVEYpPMKt9dL8AN2jq
Keep the batch size for the first three connection failures, since a throttled host only needs time, then halve it as well: a batch that is too heavy can also drop the connection. The backoff delay keeps growing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the issue?
Long IMAP imports from cPanel hosts die with
Stream was cancelled.Each chunk opens a new connection and logs in. When the host throttles repeated logins (cPHulk/firewall), the chunk fails at the greeting; the job then halves the batch (making logins more frequent), retries immediately while still blocked, and fails after 4 attempts.How does this PR resolve it?
retryImapChunkSmallernow recognises connection-level failures (isImapConnectionError: stream cancelled, connection closed, no greeting, reset/refused, timeout). For those it keeps the batch size, re-queues with a growing delay (60s × failures, capped at 10 minutes) and allows up to 10 attempts. Batch failures keep the existing halve-and-retry behaviour.enqueuegains an optionaldelaySeconds. No schema change.Steps to reproduce (optional)
main, run a long IMAP import from a host that rate-limits IMAP logins.Stream was cancelled.Demo
N/A (backend). Worker log before: four immediate retries at
greeting, thenfailed. After: retries spaced 1, 2, 3… minutes apart, batch size kept, job continues.How was it tested?
node --test tests/imap-*.test.mjs tests/jmap-*.test.mjspasses, including a new case forisImapConnectionErrormainresumed and kept running🤖 Generated with Claude Code
https://claude.ai/code/session_01LRRzcVEYpPMKt9dL8AN2jq