Simultaneous webhook requests #1735
Replies: 7 comments 20 replies
-
@dbartenstein The way the sync part works is that we first check if the object exists or not, if it doesn't then we proceed to create it. When 2 webhooks that have the same related objects hit the code very closely, it can happen that the related object doesn't exist when they check for it but by the time one of them gets to the creation part, another webhook has already created the object and hence you get the error. I've been meaning to address this issue for some time now but some other issue or feature has always taken priority. I'll get to this soon enough. In summary, it's a webhook race condition. One very naive solution is to force the webhooks to get executed sequentially but that would affect the performance a lot. But this would be extremely reliable. The other solution is to enforce checking if the object exists before creating it always. To me this seems like the way forward but not sure if I'm missing any corner cases or not. This would be more of a band aid solution to just this particular race condition. |
Beta Was this translation helpful? Give feedback.
-
@arnav13081994 thanks for your reply! We now have enabled And yes, we are looking forward to a fix of this webhook race condition. |
Beta Was this translation helpful? Give feedback.
-
@arnav13081994 we still keep receiving messages such as:
How do you think this can be best solved? |
Beta Was this translation helpful? Give feedback.
-
@arnav13081994 let me share the current status with you:
In the next couple of days we’ll see if this new configuration solves the issue. Let us know what you think about our NGINX configuration and if you see further room for improvements. |
Beta Was this translation helpful? Give feedback.
-
@arnav13081994 @jleclanche |
Beta Was this translation helpful? Give feedback.
-
I ran into the deadlock issue, too. To work around it during development I followed @dbartenstein's suggestion to use nginx to limit requests. Here is my nginx.config and docker-compose.yml docker-compose.yml
rate_limit_stripe_wh_nginx.conf:
Then use the stripe forwarding as follows: This way I can continue developing without any problems. |
Beta Was this translation helpful? Give feedback.
-
Just sharing a simple workaround we did to not encounter this error. We noticed that the error is repeatable on events related to |
Beta Was this translation helpful? Give feedback.
-
Hi!
We sometimes experience the following:
This seems to happen when two concurrent requests interfere with each other:
On second try it works.
We already have NGINX rate limiting in place 2r/s but that is not sufficient.
What’s the root cause of this and what’s best way to tackle this?
Beta Was this translation helpful? Give feedback.
All reactions