Skip to content

fix: implement retry logic for socket hang up errors in HTTP requests#1324

Open
amitsingh05667 wants to merge 2 commits intomasterfrom
fix/issue-1020-retry-socket-hang-up
Open

fix: implement retry logic for socket hang up errors in HTTP requests#1324
amitsingh05667 wants to merge 2 commits intomasterfrom
fix/issue-1020-retry-socket-hang-up

Conversation

@amitsingh05667
Copy link
Copy Markdown
Member

###Summary

  • Fixes "Socket hang up" not handled by Retry configuration #1020 — socket hang up (ECONNRESET) errors were not being retried even when retry was enabled
  • The retry logic previously only handled HTTP status codes (e.g. 429); network-level errors thrown before any response arrived bypassed it entirely
  • Added a try/catch around the fetch call in src/lib/retry.ts so network errors are now retried with the same exponential backoff logic as status code retries
  • TimeoutError is explicitly excluded from retries - a timeout is intentional and should not be retried

Changes

  • src/lib/retry.ts - wrap action() in try/catch; catch and retry network errors, rethrow TimeoutError
  • tests/lib/runtime.test.ts - 3 new tests covering the fix

Test plan

  • Retries on ECONNRESET and recovers when server becomes available within maxRetries
  • Throws after exhausting all retries on repeated socket hang up
  • Does not retry when retry: { enabled: false }
  • Timeout errors are still not retried
  • All existing 4192 tests continue to pass

@amitsingh05667 amitsingh05667 requested a review from a team as a code owner April 13, 2026 09:30
@amitsingh05667 amitsingh05667 changed the title ix: implement retry logic for socket hang up errors in HTTP requests fix: implement retry logic for socket hang up errors in HTTP requests Apr 13, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.43%. Comparing base (97a4419) to head (813295b).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1324      +/-   ##
==========================================
+ Coverage   89.42%   89.43%   +0.01%     
==========================================
  Files         384      384              
  Lines       18246    18255       +9     
  Branches     9047     8712     -335     
==========================================
+ Hits        16316    16326      +10     
+ Misses       1926     1925       -1     
  Partials        4        4              
Flag Coverage Δ
alltests 89.43% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/lib/retry.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

"Socket hang up" not handled by Retry configuration

1 participant