📌 Description
useOptimisticData (src/shared/hooks/useOptimisticData.ts) retries failed fetches up to a hardcoded max of 5 at full speed with no backoff, and never exposes the retry count to callers. This can hammer a failing backend.
💡 Why it matters: Immediate full-speed retries can amplify outages and exhaust the API.
🧩 Requirements and context
- Add exponential backoff (with jitter) between retries.
- Make max retries and base delay configurable via options.
- Expose
retryCount/isRetrying from the hook.
- Ensure aborts cancel scheduled backoff timers.
Non-functional requirements
- Must be secure, tested, and documented.
- Should be efficient and easy to review.
🛠️ Suggested execution
1. Fork the repo and create a branch
git checkout -b feat/useoptimistic-backoff
2. Implement changes
- Write/modify the relevant source:
src/shared/hooks/useOptimisticData.ts
- Write comprehensive tests:
src/shared/hooks/useOptimisticData.test.ts
- Add documentation: TSDoc
@example
- Include TSDoc doc comments
- Validate security assumptions: timers cleared on unmount/abort
3. Test and commit
- Cover edge cases: backoff timing (fake timers), abort during backoff, custom max
- Include test output and security notes in the PR description.
Example commit message
feat(hooks): exponential backoff + configurable retries in useOptimisticData
✅ Acceptance criteria
🔒 Security notes
Avoid retry storms; ensure backoff timers are always cleaned up.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
useOptimisticData(src/shared/hooks/useOptimisticData.ts) retries failed fetches up to a hardcoded max of 5 at full speed with no backoff, and never exposes the retry count to callers. This can hammer a failing backend.🧩 Requirements and context
retryCount/isRetryingfrom the hook.Non-functional requirements
🛠️ Suggested execution
1. Fork the repo and create a branch
2. Implement changes
src/shared/hooks/useOptimisticData.tssrc/shared/hooks/useOptimisticData.test.ts@example3. Test and commit
npm run testExample commit message
✅ Acceptance criteria
retryCountexposed🔒 Security notes
Avoid retry storms; ensure backoff timers are always cleaned up.
📋 Guidelines