OUT-3544: Add retry mechanisms for transient network errors#242
Draft
SandipBajracharya wants to merge 3 commits intomasterfrom
Draft
OUT-3544: Add retry mechanisms for transient network errors#242SandipBajracharya wants to merge 3 commits intomasterfrom
SandipBajracharya wants to merge 3 commits intomasterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
withRetryclassifier to cover transient 5xx (500/502/503/504), undici network failures (ECONNRESET/ECONNREFUSED/ETIMEDOUT/UND_ERR_CONNECT_TIMEOUT), andAbortSignal.timeout/AbortControllerrejections. Tunefactor: 4,retries: 4somaxTimeout: 10_000actually engages on the final attempt (back-off becomes 0.5s/2s/8s/10s ≈ 20.5s across 5 attempts).AbortSignal.timeout(EXTERNAL_FETCH_TIMEOUT_MS)(default 30s, env-overridable) to every external fetch infetch.helper.tsandcopilotAPI.manualFetch.response.okin fetch helpers; non-2xx now throws a typedHttpFetchError(status, statusText, url, body — JSON-parsed if possible, raw text otherwise) instead of cryptic JSON-parse failures.if (!res) throw new APIError(... 'no response')guards fromintuitAPI.ts(97 LOC) now that helpers throw on non-2xx; route real status throughgetMessageAndCodeFromErrorsoqb_sync_logsrecords 503 as 503 instead of 500.useSettings/useQuickbooksto wrappostFetchercalls in try/catch since helpers now throw.Worst-case op duration: 5 × 30s + 20.5s ≈ 170s, well within the webhook route's
maxDuration = 300.Test plan
yarn vitest run --project unit(72/72 passing — adds 19 cases covering 5xx retries, undici/cause network errors, TimeoutError, fetch.helper response.ok and timeout paths)yarn lint:checkclean (only pre-existing warnings)yarn prettier:checkcleanyarn tsc --noEmitcleanECONNREFUSED, confirm 5 attempts inqb_sync_logsover ~20s before final failure🤖 Generated with Claude Code