Deduplication configuration
Number of requests that shared an in-flight or windowed response.
Number of requests that triggered a real network call.
Number of currently in-flight requests.
All currently tracked keys (in-flight + window).
Execute factory for the given method/url, or return the in-flight
promise if one already exists for the same key.
HTTP method
Request URL (fully resolved)
Async function that performs the actual work
Optionalheaders: Record<string, string>Optional headers included in the key (not deduplicated by default!)
OptionalwindowMs: numberOptional per-key TTL override for this specific call. Uses the default windowMs if not provided.
Optionalsignal: AbortSignalOptional abort signal for this specific request. Falls back to the global signal from DedupOptions if not provided.
If factory throws, the error is propagated to all concurrent
waiters sharing the same promise. The entry is removed on error,
so subsequent callers will trigger a fresh factory call.
Thread-safety: In single-threaded JavaScript, the synchronous inflight.get(key)
check is atomic - there's no race condition between checking for an existing
entry and creating a new one. The first caller becomes the "leader" and all
subsequent callers within the same tick share the same promise.
Note: The default keyFn does NOT include headers in the deduplication key.
Two requests with different auth tokens to the same URL will NOT be deduplicated
unless you provide a custom keyFn that includes headers.
Get comprehensive deduplication statistics.
NOTE: inFlightCount and trackedKeys reflect snapshot time; entries may resolve asynchronously between sampling and return (non-blocking, acceptable).
Snapshot containing hits, misses, totalRequests, hitRate (0–1),
inFlightCount, and trackedKeys.
Number of requests that shared an in-flight or windowed response.
Number of requests that triggered a real network call.
Total number of requests (hits + misses).
Hit rate ratio (0–1).
Number of currently in-flight requests.
Number of tracked keys (in-flight + window).
Reset metrics counters.
Clear all in-flight entries (does NOT cancel their underlying promises).
Manually invalidate a specific key. Removes the entry from the dedup map and clears any pending timeout.
The key to invalidate
true if key was found and removed
Destroy the dedup map - clears all entries and cancels all timeouts. Use this when the dedup map is no longer needed to prevent memory leaks.
DedupMapmanages in-flight promises keyed by a request fingerprint. It is transport-agnostic — pass any async factory function.