← Back to PRs

#4086: Test/add backoff tests

by TechWizard9999 open 2026-01-29 17:08 View on GitHub →
Closes #4013 ## Summary Adds missing unit tests for `src/infra/backoff.ts` to verify exponential backoff calculations and abortable sleep behavior. ## Changes - **src/infra/backoff.test.ts**: New test file covering `computeBackoff` and `sleepWithAbort`. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> Adds unit coverage for the backoff utilities by introducing `src/infra/backoff.test.ts`, validating exponential growth, max capping, jitter bounds, and `sleepWithAbort` resolve/abort behavior. Also extends the existing unhandled rejection tests with a regression case for Node/undici `TypeError("fetch failed")` when the underlying `cause` is missing or has an unknown code, matching the updated fallback logic in `isTransientNetworkError`. Overall this fits into the `src/infra` layer by strengthening the safety net around retry timing and the gateway’s “don’t crash on transient network issues” behavior. <h3>Confidence Score: 4/5</h3> - This PR is safe to merge; changes are tests and a small tweak to transient error classification. - No obvious functional regressions in the updated `fetch failed` handling, and the new tests exercise the intended behavior. Main concern is test reliability: one jitter test is probabilistic and the fake-timers test doesn’t guarantee cleanup on failure. - src/infra/backoff.test.ts (test determinism and timer cleanup) <!-- greptile_other_comments_section --> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs