gabriel-a commented 12 minutes ago Author
Summary
Consolidates the three retry implementations in the payments worker behind one shared retryWithBackoff() helper so every call site gets the same exponential backoff with jitter.
Changes
- Add
workers/lib/retry.tswithretryWithBackoff()(max 5 attempts, jittered exponential delay) - Migrate
charge.ts,refunds.ts, andpayouts.tsto the shared helper - Remove the three inline retry loops and their duplicated constants
Testing
npm test -- workers/lib/retry.test.ts— 12 passednpm test -- workers/payments— 84 passednpx tsc --noEmit— clean
Risk Assessment
Low-risk refactor: behavior is unchanged at every call site and the new helper is fully covered by unit tests.
Risk score: 3/10
Overall risk: Low
Concerns
- Jitter changes retry timing slightly; alert thresholds tuned to the old fixed delays may need a look.
payouts.tspreviously retried 7 times; the shared default is 5.
Verdict
Safe to ship. Pure consolidation with test coverage on the new path; the two concerns are tuning, not correctness.