Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin-stripe): properly resolve promise in webhook processing to fix serverless deployment issues and database errors #10685

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tomtana
Copy link

@tomtana tomtana commented Jan 20, 2025

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:

  • the webhook immediately returns status 200. In serverless execution mode the serverless function may terminate before the webhook is processed and the await on the toplevel is not bound to the serverless function anymore -> leads to infinite waiting. This happens randomly.
  • Another side-effect in the serverless execution mode is that the logs are not attached to the proper api function route api/stripe/webhooks but appear on any other route e.g. api/orders -> this happens because the webhook is not bound to the serverless function api/stripe/webhooks and processed whenever another function is triggered
  • when multiple webhook events come in at the same time and transactions are enabled (tested mongodb), they can cause database errors like Error: 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 occurs

I described this issue further in the #10639 . At that point I wasn't sure yet if I was dealing with a bug.

Fixes #
#10639

@tomtana tomtana changed the title fix(plugin-stripe): properly resolve promise in webhook processing fix(plugin-stripe): properly resolve promise in webhook processing to fix serverless deployment issues and database errors Jan 20, 2025
@tomtana tomtana marked this pull request as ready for review January 20, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant