OpenBazaar / openbazaar-go

OpenBazaar 2.0 Server Daemon in Go
MIT License
994 stars 283 forks source link

Orders are stuck when Vendor Store is "off" but Buyer has opportunity to fund before getting offline ERROR state #1669

Open placer14 opened 5 years ago

placer14 commented 5 years ago

We've uncovered an interesting race condition in the order handling. The scenario works as follows:

In this outcome, the buyer's funds appear to remain stuck in the order awaiting the vendor node to produce either Reject or Accept/Refund messages for the buyer to get their funds back.

Unclear whether the ERROR state is being returned to the buyer node or not. This might be enough for the Buyer to initiate a refund.

Manual intervention is required on the vendor side to remove the ERROR state so the vendor can reject the order as usual.

Proposed fix would allow the ERROR state to be sent to the buyer so the funds can be automatically retrieved. Need to investigate the feasibility of this fix.

placer14 commented 5 years ago

The fix that I'm currently pursuing is an extraction of the normal behavior when a buyer CANCELs their own order, and using the same behavior in response to the CANCEL on the buyer side as well as an ERROR from the vendor side. Should be ready tomorrow.

Edit, more context: The ERROR state is, in fact, being returned to the buyer. But the node is waiting for the user to hit a button to initiate the refund. It's a curious extra step that neither @cpacia nor @jjeffryes have any ideas why this might be needed. So the fix looks like automatically attempting a refund if one is needed when an order enters ERROR state (as if the user had automatically pressed the cancel button in the UI).