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

Weird race condition when updating a cart before initializing payment #7147

Open
HCaupert opened this issue Apr 25, 2024 · 0 comments
Open

Comments

@HCaupert
Copy link

HCaupert commented Apr 25, 2024

Hello everyone,

We're currently facing an issue with our Medusa integration. The problem arises when we:

Update a cart by adding the user email (from anonymous users)
Immediately call createPaymentSessions afterwards
It appears that updating the cart triggers a cart.customer_updated event, which has an associated listener. That triggers an updatePayment against the PaymentProcessor

The issue arises from a race condition; depending on its outcome, we might create the payment session before the listener has finished its processing. Since our custom payment processor cannot update sessions, each time we call updatePayment, a new PSP payment session is created.

This results in two sessions:

Session1, which is created and returned to the storefront upon calling createPaymentSessions
Session2, which is created but lost once the listener finishes its processing

Although it's difficult to reproduce and somewhat of an edge case, it's proving to be a significant annoyance, and we simply cannot ignore it any longer 😢

Any help/info/advice would be super appreciated, thanks alot !

Medusa version : any recent version
Node.js version: any node version (on all platforms)
Database: postgres
Operating system: any unix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant