Skip to content

Implemented the generic in-flight request deduplication primitive - #486

Merged
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
Medo99-olo:Implemented-the-generic-in-flight-request-deduplication-primitive
Aug 30, 2026
Merged

Implemented the generic in-flight request deduplication primitive#486
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
Medo99-olo:Implemented-the-generic-in-flight-request-deduplication-primitive

Conversation

@Medo99-olo

Copy link
Copy Markdown
Contributor

Description

Implements a generic in-flight request deduplication primitive for the GuildPass SDK. This allows concurrent callers requesting the same logical operation to share one underlying asynchronous execution, reducing duplicate network requests and ensuring consistent timing behavior.

Semver impact: minor

Linked Issue

Closes #454

Type of Change

  • 🐛 Bug fix (patch)
  • ✨ New feature / method (minor)
  • 💥 Breaking change (major)
  • 📝 Documentation / TypeDoc update
  • 🔧 Chore / refactor
  • 🧪 Tests only

Changes Made

  • src/utils/requestDeduplicator.ts - New module implementing RequestDeduplicator class for generic in-flight request deduplication
  • src/utils/index.ts - Added export for requestDeduplicator module
  • src/index.ts - Added export to main package index
  • tests/unit/requestDeduplicator.test.ts - Comprehensive unit tests covering success, failure, retry, parallel execution, capacity handling, and edge cases

Public API Changes

// New exports:
export class RequestDeduplicator<T>
export interface RequestDeduplicatorOptions
export type AsyncProducer<T>
export class CapacityExceededError

Test Evidence

pnpm test:run output:
✓ tests/unit/requestDeduplicator.test.ts (33 tests) 387ms
Test Files  19 passed (19) 
     Tests  506 passed (506)

Build Evidence

pnpm build output:
ESM dist/index.js     53.22 KB
ESM dist/index.js.map 137.03 KB
ESM ⚡️ Build success in 335ms
DTS Build start
DTS ⚡️ Build success in 2060ms
DTS dist/index.d.ts 43.77 KB

Checklist

  • I have read CONTRIBUTING.md
  • This PR is linked to an open issue
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test:run passes — all tests green
  • pnpm build succeeds — dist/ generated cleanly
  • All new public methods/types have TypeDoc comments
  • New behaviour is covered by at least one Vitest unit test
  • No new runtime dependencies added without prior maintainer approval
  • docs/ updated if public API changed
  • examples/ updated if new usage patterns were added
  • Backwards compatibility maintained (or breaking change clearly noted above)

Additional Notes

The implementation is completely independent of HTTP transport, cache, or endpoint implementations as required. It provides a generic concurrency primitive that can be used throughout the SDK for deduplicating any async operation based on a string key. The module includes configurable capacity limits and optional short-lived result retention, both clearly separated from the core in-flight deduplication semantics.

@Lakes41
Lakes41 merged commit b3f884c into Adamantine-guild:main Aug 30, 2026
2 checks passed
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.

Build a deterministic SDK request deduplication layer for concurrent identical reads

3 participants