Skip to content

Conversation

@zisshh
Copy link

@zisshh zisshh commented Nov 17, 2025

Problem Brief

Implement an opt-in request coalescing feature that automatically detects identical in-flight requests and shares a single network call, returning the same response (or error) to all callers.

Agent Instructions

  1. Implement request coalescing enabled per-request via a request option.
  2. Identity: Requests are considered identical when they have the same HTTP method, URL (including query parameters), headers, and body. Query parameters are considered identical regardless of order. Header names are compared case-insensitively.
  3. Interoperability with existing features:
    • Interceptors: Must be called once per unique network request.
    • Caching: Completed requests must not interfere with subsequent identical requests.
  4. Cancellation, timeouts, and error propagation:
    -Cancellation: If a subscriber aborts, only that subscriber receives an AbortError. If all subscribers abort, the underlying network request should be canceled.
    -Timeouts: Timeouts are respected without creating duplicate in-flight requests.
    -Error Propagation: Client-facing errors are the standard ofetch FetchError with status/statusText populated from the HTTP response.
  5. Abort handling: It must not cause unhandled promise rejections.
  6. Configuration: Support both per-request ({ dedupe: true }) and global (via $fetch.create({ dedupe: true })) enablement.
  7. Maintain backward compatibility and type safety. When dedupe is omitted or false, behavior MUST match existing ofetch semantics (no coalescing).

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.

2 participants