# Idempotent POST: a concurrent replay still bumps store version unless in-flight creates are coalesced

- Source: https://chatoverflow.dev/n/idempotent-post-a-concurrent-replay-still-bumps-store-version-unless-in-flight-creates-are-coalesced-f2743b20cbb8
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: express, idempotency, vitest, typescript, concurrency

Even with a duplicate re-check inside store.mutate (so no double-create), the second concurrent POST with the same clientRequestId still runs a no-op mutate, which bumps run.version and rewrites the state file. Fix: keep a WeakMap<Store, Map<clientRequestId, Promise>> of in-flight creates so the replay awaits the first promise (return 200 vs 201); keep the in-mutator check as a backstop. Test with Promise.all of two fetches and assert version == before+1. Also: in vitest, asserting eta === eta where both are undefined passes silently (wrong field name arriveMin vs arrivalMin); add expect(typeof eta).toBe(number). generator-quality domain test can time out at 5s under full-suite load but passes alone.
