Skip to content

OUT-3544: Add retry mechanisms for transient network errors#242

Draft
SandipBajracharya wants to merge 3 commits intomasterfrom
OUT-3544
Draft

OUT-3544: Add retry mechanisms for transient network errors#242
SandipBajracharya wants to merge 3 commits intomasterfrom
OUT-3544

Conversation

@SandipBajracharya
Copy link
Copy Markdown
Collaborator

Summary

  • Expand withRetry classifier to cover transient 5xx (500/502/503/504), undici network failures (ECONNRESET/ECONNREFUSED/ETIMEDOUT/UND_ERR_CONNECT_TIMEOUT), and AbortSignal.timeout/AbortController rejections. Tune factor: 4, retries: 4 so maxTimeout: 10_000 actually engages on the final attempt (back-off becomes 0.5s/2s/8s/10s ≈ 20.5s across 5 attempts).
  • Add AbortSignal.timeout(EXTERNAL_FETCH_TIMEOUT_MS) (default 30s, env-overridable) to every external fetch in fetch.helper.ts and copilotAPI.manualFetch.
  • Validate response.ok in fetch helpers; non-2xx now throws a typed HttpFetchError (status, statusText, url, body — JSON-parsed if possible, raw text otherwise) instead of cryptic JSON-parse failures.
  • Remove 15 dead if (!res) throw new APIError(... 'no response') guards from intuitAPI.ts (97 LOC) now that helpers throw on non-2xx; route real status through getMessageAndCodeFromError so qb_sync_logs records 503 as 503 instead of 500.
  • Update useSettings/useQuickbooks to wrap postFetcher calls 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:check clean (only pre-existing warnings)
  • yarn prettier:check clean
  • yarn tsc --noEmit clean
  • Manual smoke against QBO sandbox: trigger a webhook, point one outbound at an unroutable host to force ECONNREFUSED, confirm 5 attempts in qb_sync_logs over ~20s before final failure
  • UI spot-check: product/invoice settings save flow still surfaces error state correctly when the API route returns non-2xx

🤖 Generated with Claude Code

SandipBajracharya and others added 3 commits May 6, 2026 22:34
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 6, 2026

@vercel
Copy link
Copy Markdown

vercel Bot commented May 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
quickbooks-sync Building Building May 6, 2026 5:05pm
quickbooks-sync (dev) Ready Ready Preview, Comment May 6, 2026 5:05pm

Request Review

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.

1 participant