You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See this gist for integration tests that expose the issue. Specifically the last spec is failing.
When two users try to purchase the last item remaining from a non-backordeable stock location at the same time then the last one will experience an unhandled error Spree::Order::InsufficientStock. This happens only if there is a second backorderable stock location for the product.
The error is generated by this line in Spree::Order model:
So, controller validations (provided here via before_action :ensure_sufficient_stock_lines) are following a different path, calling different methods, and this causes that error to be raised later in the order finalization process. Unifying the process seems to me the most reasonable way to fix the issue.
As a side note, but I think this is quite relevant, if the customer restarts the checkout process at least from the delivery step then the error does not happen anymore, as the order shipments are recreated from scratch this time using the backorderable stock location.
Expected behavior
IMHO the customer should be redirected to the checkout delivery page, showing them an error message that suggests to restart the checkout process due to some changes in product availabilities.
Actual behavior
When the customer presses the order confirmation button then checkout process is halted by Spree::Order::InsufficientStock. The customer experiences a 500 server error page.
System configuration
Solidus Version:
master and previous versions, at least down to 2.6.x
Extensions in use:
none
The text was updated successfully, but these errors were encountered:
Steps to reproduce
See this gist for integration tests that expose the issue. Specifically the last spec is failing.
When two users try to purchase the last item remaining from a non-backordeable stock location at the same time then the last one will experience an unhandled error
Spree::Order::InsufficientStock
. This happens only if there is a second backorderable stock location for the product.The error is generated by this line in
Spree::Order
model:So, controller validations (provided here via
before_action :ensure_sufficient_stock_lines
) are following a different path, calling different methods, and this causes that error to be raised later in the order finalization process. Unifying the process seems to me the most reasonable way to fix the issue.As a side note, but I think this is quite relevant, if the customer restarts the checkout process at least from the
delivery
step then the error does not happen anymore, as the order shipments are recreated from scratch this time using the backorderable stock location.Expected behavior
IMHO the customer should be redirected to the checkout
delivery
page, showing them an error message that suggests to restart the checkout process due to some changes in product availabilities.Actual behavior
When the customer presses the order confirmation button then checkout process is halted by
Spree::Order::InsufficientStock
. The customer experiences a500 server error
page.System configuration
Solidus Version:
master
and previous versions, at least down to2.6.x
Extensions in use:
none
The text was updated successfully, but these errors were encountered: