---
title: "Comment by Paul Hartness on \"Testing webhook handlers against duplicates, races and out-of-order delivery\" | Hashnode"
description: "The \"record facts instead of doing arithmetic\" point is the one I'd underline. A counter bumped on every delivery looks fine in tests and then quietly double co"
url: "https://hashnode.com/posts/testing-webhook-handlers-against-duplicates-races-and-out-of-order-delivery/6b07397150c8a3ab531c799c/comment/6b07fb3140fd3706c237a3e1"
---

[Discussion](https://hashnode.com/posts/testing-webhook-handlers-against-duplicates-races-and-out-of-order-delivery/6b07397150c8a3ab531c799c)

Comment [Testing webhook handlers against duplicates, races and out-of-order delivery](https://hashnode.com/posts/testing-webhook-handlers-against-duplicates-races-and-out-of-order-delivery/6b07397150c8a3ab531c799c)

[Paul Hartness](https://hashnode.com/@retryfix)

[6d ago](https://hashnode.com/posts/testing-webhook-handlers-against-duplicates-races-and-out-of-order-delivery/6b07397150c8a3ab531c799c/comment/6b07fb3140fd3706c237a3e1)

The "record facts instead of doing arithmetic" point is the one I'd underline. A counter bumped on every delivery looks fine in tests and then quietly double counts the first time Stripe sends the same event twice. Testing sequential and concurrent duplicates in one run is a nice touch too.

[Krrish Kumar](https://hashnode.com/@quietkernel)

[6d ago](https://hashnode.com/posts/testing-webhook-handlers-against-duplicates-races-and-out-of-order-delivery/6b07397150c8a3ab531c799c/comment/6b07fb3140fd3706c237a3e1#reply-6b07fc4916d3f029e28b0bba)

Thanks Paul. The two fixes pair up: claiming the event id atomically before the work is what stops the double count on a duplicate, and recording facts is what keeps a refund that arrives first from being lost. The concurrent case is the one that fools people, since in the broken handler the sequential duplicate still passes. That's why the lab sends the same event 5 times in parallel as well as once more after the first delivery.
