📌 Description
useOptimisticData caches per hook instance via its own cacheRef, so two components mounting simultaneously (e.g. DiscoverPage and a nav widget both calling getLandingStats/getPublicProjects) each fire their own request. Add a small in-flight dedupe map keyed by endpoint+query at the apiRequest GET layer so concurrent identical GETs share a single promise. This reduces duplicate network traffic without a heavy data-fetching library.
💡 Why it matters: Independent components requesting the same public data multiply network load and backend pressure.
🧩 Requirements and context
- Maintain a module-level
Map<string, Promise<unknown>> for in-flight GETs.
- Key on method+url; only dedupe idempotent GET/HEAD.
- Clear the map entry on settle (resolve or reject).
- Never dedupe authenticated mutating requests.
- Make dedupe opt-out via an option for callers that need a fresh request.
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 perf/api-inflight-dedupe
2. Implement changes
- Write/modify the relevant source:
src/shared/api/client.ts
- Write comprehensive tests:
src/shared/api/client.test.ts
- Add documentation: inline TSDoc on the dedupe behavior
- Include TSDoc doc comments
- Validate security assumptions: auth and abort signals respected per caller
3. Test and commit
- Cover edge cases: concurrent identical GETs share a promise; rejection clears the entry; aborts isolated per caller
- Include test output and security notes in the PR description.
Example commit message
perf(api): dedupe concurrent identical GET requests
✅ Acceptance criteria
🔒 Security notes
Only dedupe by URL+method for unauthenticated GETs to avoid leaking one user's response to another via shared promises.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
useOptimisticDatacaches per hook instance via its owncacheRef, so two components mounting simultaneously (e.g.DiscoverPageand a nav widget both callinggetLandingStats/getPublicProjects) each fire their own request. Add a small in-flight dedupe map keyed by endpoint+query at theapiRequestGET layer so concurrent identical GETs share a single promise. This reduces duplicate network traffic without a heavy data-fetching library.🧩 Requirements and context
Map<string, Promise<unknown>>for in-flight GETs.Non-functional requirements
🛠️ Suggested execution
1. Fork the repo and create a branch
2. Implement changes
src/shared/api/client.tssrc/shared/api/client.test.ts3. Test and commit
npm test -- clientExample commit message
✅ Acceptance criteria
🔒 Security notes
Only dedupe by URL+method for unauthenticated GETs to avoid leaking one user's response to another via shared promises.
📋 Guidelines