Tech
The webhook dedupe everyone copies has a hole in it
If you have ever searched for how to stop processing the same webhook twice, you have seen this snippet:
INSERT INTO processed_events ( event_key )
VALUES ( $ 1 )
ON CONFLICT ( event_key ) DO NOTHING
RETURNING event_key ;
Got a row back, you are the first one here, do the work. Got nothing, somebody already handled it, return 200 and move on. It is correct, it is atomic, and it beats the check-then-insert version that races itself under load.
...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to