One-line idempotency middleware for Express #7413
violetta98
started this conversation in
Show and tell
Replies: 1 comment 1 reply
|
As others have already written in other projects, where you have opened similar discussions, what you're trying to do is wrong and a misunderstanding of the problem (and vocabulary). |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
A client retries a
POST, your handler runs twice, and someone gets charged twice. It's the kind of bug you hear about from support rather than from a test.Send the same request twice and the second one comes back with
idempotency-replayed: true, handler never touched. Redis, Postgres, Mongo or DynamoDB in production.It also survives the awkward case: if a worker dies mid-charge, the key frees itself instead of staying stuck, and that worker's late write gets rejected rather than overwriting the real result.
Zero dependencies, Apache-2.0: https://github.com/idemkit/idemkit
If you find it useful, a star would be much appreciated.
All reactions