fix(plugin-stripe): properly resolve promise in webhook processing to fix serverless deployment issues and database errors #10685
+36
−27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Resolve promise of stripe webhooks directly in the webhook handling to fix issues with serverless deployment and database issues with transactions enabled.
Why?
Not resolving the webhooks directly in the webhook handling leads to a lot of very hard to debug side-effects:
api/stripe/webhooks
but appear on any other route e.g.api/orders
-> this happens because the webhook is not bound to the serverless functionapi/stripe/webhooks
and processed whenever another function is triggeredError: MongoServerError: Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction.
. The reason for this is that the webhooks are not processed sequentially but all at the same time -> a transaction conflict occursI described this issue further in the #10639 . At that point I wasn't sure yet if I was dealing with a bug.
Fixes #
#10639