Skip to content

fix(api): include Idempotency-Key in apiRequest deduplication key (Fixes #869) - #955

Open
Lion4467cat wants to merge 1 commit into
MergeFi:mainfrom
Lion4467cat:fix/issue-869-idempotency-dedup
Open

Lion4467cat wants to merge 1 commit into
MergeFi:mainfrom
Lion4467cat:fix/issue-869-idempotency-dedup

Conversation

@Lion4467cat

@Lion4467cat Lion4467cat commented Nov 14, 2026 •

Copy link
Copy Markdown

Fixes #869

What changed

  • Added getIdempotencyKeyHeader(headers?: HeadersInit) in src/lib/api.ts (handling plain header objects, Headers instances, and header entry tuples case-insensitively) and included the extracted Idempotency-Key in requestKey(...).
  • Added unit tests in src/lib/api.test.ts verifying that concurrent apiPost / apiRequest calls with distinct Idempotency-Key headers execute as separate requests while identical keys still coalesce, including Headers and tuple-array forms (strictly typed under noUncheckedIndexedAccess).
  • Resolved upstream merge-conflict syntax remnants in src/lib/api.ts and src/lib/utils.ts so the test suite and linter execute cleanly.

Why

  • apiRequest previously deduplicated in-flight requests solely by method + path + body, ignoring the Idempotency-Key header attached by apiPost. Two claim or funding requests with identical {} bodies and rotated idempotency keys coalesced into the first promise, preventing the rotated key from ever reaching the backend.

How to test

  • npx jest src/lib/api.test.ts --no-coverage (8 passed, 8 total)
  • npx eslint src/lib/api.ts src/lib/api.test.ts src/lib/utils.ts (0 errors, 0 warnings)

@vercel

vercel Bot commented Nov 14, 2026

Copy link
Copy Markdown

@Lion4467cat is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

@Lion4467cat
Lion4467cat force-pushed the fix/issue-869-idempotency-dedup branch from 7b8aa88 to b0f3e59 Compare November 14, 2026 10:40

This branch has not been deployed

No deployments
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.

apiRequest deduplicates by method+path+body but ignores the Idempotency-Key header, so two distinct claims coalesce into one request

1 participant