Race condition: new profile gets saved twice in ShippingInformation::validatePaneForm(), resulting in duplicate UUID exception

Created on 13 September 2022, almost 2 years ago
Updated 19 December 2023, 6 months ago

Problem/Motivation

\Drupal\commerce_shipping\Plugin\Commerce\CheckoutPane\ShippingInformation::validatePaneForm() saves a shipping profile if it is still new.

I haven't been able to reproduce manually, but with a javascript behat test that basically does this, it happens basically every time on 2.3+:

 When I am at "/en/cart"
    And I press "Checkout"
    Then I fill in "..." for "First name"
    And I fill in "..." for "Last name
    # ... Fill out all other required fields until shipping ajax triggers
    [...] 
    And I select the radio button with partial label "Shipment"

This is then happening fast enough that the validation starts before the order saving from the initial ajax request is completed (which is when the form state is actually persisted).

I'm actually not 100% sure why it doesn't always happen, so maybe I don't understand this 100% yet.

A workaround in the test is to just wait a second before selecting a different shipment method.

Proposed resolution

Not fully thought through, but one possible solution could be to attempt the load the profile by UUID before trying to save it if it's new, to double-check that.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland Berdir Switzerland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • I am currently experiencing this issue as well.

    I have no way to reproduce this issue but is seeing the same errors in the log.

    Any suggestions on how to resolve this?

    Thanks

Production build 0.69.0 2024