Skip to content

fix: add optimistic concurrency to cancelOrderItem mutation - #6882

Closed
atharv-sys32 wants to merge 1 commit into
reactioncommerce:trunkfrom
atharv-sys32:fix/reaction-6493-concurrent-cancel
Closed

fix: add optimistic concurrency to cancelOrderItem mutation#6882
atharv-sys32 wants to merge 1 commit into
reactioncommerce:trunkfrom
atharv-sys32:fix/reaction-6493-concurrent-cancel

Conversation

@atharv-sys32

Copy link
Copy Markdown

Parallel calls to cancelOrderItem for different fulfillment groups of the same order would race: each call reads the order, modifies its copy of the shipping groups, and writes the full updated shipping array back — overwriting changes from the concurrent call.

Added optimistic concurrency control using updatedAt. If the order was modified by another request between read and write, findOneAndUpdate fails to match and throws an error, preventing silent data loss.

Fixes #6493

@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1816869

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

Parallel calls to cancelOrderItem for different fulfillment groups of
the same order would race: each call reads the order, modifies its
copy of the shipping groups, and writes the full updated shipping
array back — overwriting changes from the concurrent call.

Added optimistic concurrency control using updatedAt. If the order
was modified by another request between read and write, findOneAndUpdate
fails to match and throws an error, preventing silent data loss.

Fixes reactioncommerce#6493

Signed-off-by: Atharv Pandey <atharvpandey245@gmail.com>
@atharv-sys32
atharv-sys32 force-pushed the fix/reaction-6493-concurrent-cancel branch from 8419363 to 1816869 Compare July 30, 2026 19:17
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.

cancelOrderItem can't deal with concurrent requests properly

1 participant