Skip to content

Build a deterministic SDK request deduplication layer for concurrent identical reads #454

Description

@Lakes41

Difficulty: Expert
Type: Feature
Recommended labels (if available in this repo): performance, backend, consistency, expert

Background

Applications using GuildPass SDK may trigger identical read requests concurrently, for example when multiple components request the same membership or access data during the same render cycle.

Launching duplicate network requests wastes resources and can produce inconsistent timing behaviour.

This issue introduces a generic in-flight request deduplication primitive without coupling it to any GuildPass endpoint.

Problem

There is currently no SDK mechanism for sharing one in-flight Promise between callers requesting the same logical operation.

A naive cache is not sufficient because completed response caching and in-flight deduplication have different semantics.

Expected Outcome

Implement a reusable request deduplicator that ensures concurrent callers using the same deduplication key share one underlying asynchronous execution.

Suggested Implementation

The module should:

  • accept a deterministic string key;
  • accept an asynchronous producer function;
  • execute the producer only once while the key is in flight;
  • return the same logical result to all concurrent callers;
  • remove entries after success;
  • remove entries after failure;
  • avoid permanently caching completed results;
  • ensure a failed execution can be retried later;
  • optionally support configurable short-lived result retention only if clearly separated from in-flight semantics;
  • expose current in-flight count for diagnostics if useful;
  • bound the number of in-flight entries;
  • define behaviour when capacity is exceeded;
  • avoid leaking unresolved entries when producers reject;
  • remain independent of HTTP and GuildPass domain types.

Acceptance Criteria

  • Two concurrent calls with the same key execute the producer exactly once.
  • All callers receive the same successful result.
  • All callers observe the same failure when the shared producer rejects.
  • Failed executions are removed so a later attempt can retry.
  • Successful executions are removed after completion unless explicit retention is configured.
  • Different keys execute independently.
  • Capacity limits are enforced deterministically.
  • No unresolved entry remains after producer settlement.
  • Unit tests cover success, failure, retry, parallel different keys, and capacity handling.
  • Tests use controlled promises to prove exactly-once execution.
  • pnpm typecheck passes.
  • pnpm build passes.
  • pnpm test passes.
  • No network request or response caching implementation is included.

Likely Affected Files/Directories

src/transport/ or src/utils/
tests/

Independence Requirement

This issue must remain a generic concurrency primitive and must not depend on the HTTP transport, cache, or endpoint implementations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesThird CampaignOfficial FWC26 campaign issue — eligible for campaign scoring and rewardsbackendBackend services, application logic, persistence integration, and server-side functionalityconsistencyPattern and convention standardization across the codebase for uniformityexpertExpert difficulty tasks requiring deep expertise and architectural decision-makingperformancePerformance optimization or latency/throughput improvement work

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions