Effect Idempotency Key Store
An execution guard that makes retried requests safe: every request carries an idempotency key, and the store makes the key the single author of execution. The in-flight slot is claimed with one atomic Ref.modify, so of two racing duplicates exactly one runs the effect while the other awaits a Deferred the winner completes, and a late retry after completion replays the stored result inside its TTL without re-executing. Failures propagate to every waiting duplicate and release the key, so a declined card can be retried deliberately while a double charge stays impossible. Solves the double charge on retry and the check-then-insert race. Pinned to effect 4.0.0-beta.98.
npx shadcn@latest add https://ui.aryank.space/r/effect-idempotency-key-store.jsonInstalls from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.
The client times out and retries, but the first request already reached the processor. Both requests execute, and the charged total lands at 9998 cents for a 4999 cent order. Watch the odometer flash red on the second charge: that write should never have happened.