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(core-flows, types): reservation of shared inventory item #11403

Merged
merged 4 commits into from
Feb 13, 2025

Conversation

fPolic
Copy link
Contributor

@fPolic fPolic commented Feb 11, 2025

What

  • if a cart contains variants that share inventory items, reservation of the item would fail also causing complete cart to fail
  • include completed_at when compensating cart update
  • account for multiple reservations of the same item when creating the locking key

CLOSES SUP-587

@fPolic fPolic requested a review from a team as a code owner February 11, 2025 16:31
Copy link

changeset-bot bot commented Feb 11, 2025

⚠️ No Changeset found

Latest commit: 91c1090

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Feb 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference 🔄 Building (Inspect) Visit Preview 💬 Add feedback Feb 11, 2025 6:44pm
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 11, 2025 6:44pm
5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference-v2 ⬜️ Ignored (Inspect) Visit Preview Feb 11, 2025 6:44pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview Feb 11, 2025 6:44pm
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Feb 11, 2025 6:44pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Feb 11, 2025 6:44pm
resources-docs ⬜️ Ignored (Inspect) Visit Preview Feb 11, 2025 6:44pm

const reservations = await locking.execute(inventoryItemIds, async () => {
const lockingKeys = Array.from(new Set(inventoryItemIds))

const reservations = await locking.execute(lockingKeys, async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: if we create multiple reservations of the same inventory item in this step (one for each item in a cart that has items which share the inventory item) we need to deduplicate keys otherwise we will have deadlock. We need to update this in few more places if you agree with the approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch.

const reservations = await locking.execute(inventoryItemIds, async () => {
const lockingKeys = Array.from(new Set(inventoryItemIds))

const reservations = await locking.execute(lockingKeys, async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch.

@fPolic fPolic changed the title fix(core-flows): reservation of shared inventory item fix(core-flows, types): reservation of shared inventory item Feb 11, 2025
@kodiakhq kodiakhq bot merged commit bbef0da into develop Feb 13, 2025
23 checks passed
@kodiakhq kodiakhq bot deleted the fix/reservations-shared-inventory-item branch February 13, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants