-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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(medusa): Transaction lock issues on create/update cart items #2612
Conversation
🦋 Changeset detectedLatest commit: 75b9822 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
d115c30
to
2066980
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix will require the caller of addLineItem
to always bring a cart's line items to a valid state. I don't think we should force the caller to hold this responsibility.
Could we instead update the isolation level in the controller to be serializable and throw a 409 if there are read/write dependencies?
If we make the endpoint idempotent, we can add retry functionality in the js client that automatically retries the request if we reach a 409. |
Yes sure, i should add idempotency support in that case but yeah if we explicitly explain to the consumer that in some cases it needs to be retried i am ok with that 👍 i thought about it but wasn’t sure as it transform the endpoint management 🥹 |
packages/medusa/src/api/routes/store/carts/create-line-items/handler-steps.ts
Outdated
Show resolved
Hide resolved
ca034d5
to
f1f302a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wdyt of avoiding joining all items in addLineItem like I have done here: develop...fix/serialized-add-to-cart#diff-b1b00df3e31608f5099498d5dc7dfc5f92032809e1e16cbd7b1e9a85304c8edbR578
Curious if this would be more performant in cases where the cart holds many items, despite the extra db queries?
153f5e4
to
902aefe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, will let @srindom take a final stab at it as he had a couple of suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
what
The fixes will be done in multiple steps
FIXES CORE-801