vuestorefront / vue-storefront-1

The open-source frontend for any eCommerce. Built with a PWA and headless approach, using a modern JS stack. We have custom integrations with Magento, commercetools, Shopware and Shopify and total coverage is just a matter of time. The API approach also allows you to merge VSF with any third-party tool like CMS, payment gateways or analytics. Newest updates: https://blog.vuestorefront.io. Always Open Source, MIT license.
https://www.vuestorefront.io
MIT License
19 stars 13 forks source link

wait until updateItem finished in stockSync function #417

Open pschaub opened 4 years ago

pschaub commented 4 years ago

I have seen that inside stockSync of core/modules/cart/store/actions/synchronizeActions.ts there are 2 dispatch calls without an await. Please check if the missing await could result into weird race-condition behaviour.

Should we wait until the dispatch call finished?

  1. https://github.com/OetkerDigital/belvini-storefront/blob/a5e9e9ee9c2c43444790592ae2475f436f859d01/src/pwa/core/modules/cart/store/actions/synchronizeActions.ts#L95
  2. https://github.com/OetkerDigital/belvini-storefront/blob/a5e9e9ee9c2c43444790592ae2475f436f859d01/src/pwa/core/modules/cart/store/actions/synchronizeActions.ts#L102

Current:

dispatch('updateItem', { ... })

Suggestion:

await dispatch('updateItem', { ... })
Fifciu commented 3 years ago

Rather not but please make sure @lukaszjedrasik