Javid @javid.dev · Nov 5

Saw this "funny race condition" tweet. Many developers forget that events are most of the time unordered and might even be duplicated. When working with Stripe Webhooks (or others), you will, of course, get a race condition when you subscribe to multiple events. Three things to always consider:

0 likes 1 replies

?

Replies

Javid · Nov 5

1. Events are unordered. Use a conditional put. It doesn't matter whether your database supports it out of the box or not. For example, you can compare the timestamp of the event with the timestamp of the last event you processed/stored. If the event is older, discard it as it's a duplicated event