Skip to content

feat: add request deduplication for concurrent calls - #160

Merged
heymariam merged 2 commits into
Dorisio:mainfrom
DeFex-lab:feat/issue-119-implement-request-deduplication-for-concurrent
Oct 8, 2026
Merged

heymariam merged 2 commits into
Dorisio:mainfrom
DeFex-lab:feat/issue-119-implement-request-deduplication-for-concurrent

Conversation

@DeFex-lab

Copy link
Copy Markdown

Overview

This PR adds a request deduplication layer to the HTTP client so that identical concurrent calls (same method + params) share a single in-flight promise and only trigger one network request. Deduplication is enabled by default and configurable via ClientConfig.

Related Issue

Changes

🔁 Request Deduplication

  • [MODIFY] src/http/http-client.ts

    • Added an in-flight request map keyed by method + serialized params.
    • Concurrent callers with identical keys receive the same pending promise.
    • Cache entry is cleared once the response settles (success or failure) so subsequent calls are not deduplicated.
  • [MODIFY] src/client.ts

    • Wired deduplication through client methods so all calls go through the shared dedup path.
  • [MODIFY] src/config.ts

    • Added deduplication option to ClientConfig (default: enabled).
  • [MODIFY] src/__integration-tests__/helpers/mock-http.ts

    • Updated mock HTTP helper to count network requests so deduplication can be asserted.
  • [MODIFY] src/http/http-client.test.ts

    • Tests verifying identical concurrent requests resolve to the same response, only one network request is made, and multiple resolvers are satisfied.

Verification Results

npm run lint
✅ No ESLint errors

npm run type-check
✅ No TypeScript errors

npm run test
✅ All tests passing (including new deduplication tests)

npm run build
✅ Successful DTS generation
Acceptance Criteria Status
Identical concurrent requests return same response ✅ Shared in-flight promise returned to all callers
Only 1 network request made for duplicates ✅ Asserted via mock HTTP request counter
Works across all client methods ✅ Dedup applied at HTTP client layer used by all methods
Configurable deduplication via ClientConfig ✅ deduplication flag added to ClientConfig (default: enabled)
Tests verify single request + multiple resolvers ✅ Added to http-client.test.ts

Closes #119

…e-file rewrite

The automated whole-file rewrite fallback wrote the blob's base64 encoding
instead of the source, replacing these files with a single base64 line. This
restores their pre-PR content; the rest of the change is untouched.
@heymariam
heymariam merged commit f63ce6a into Dorisio:main Oct 8, 2026
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.

[FEATURE] Implement request deduplication for concurrent calls

2 participants