Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Fix runaway state change loop for showing validation errors in event subscription. #2119

Merged
merged 1 commit into from
Apr 4, 2020

Conversation

nerrad
Copy link
Contributor

@nerrad nerrad commented Apr 3, 2020

While working on #2054, in testing I noticed that we were getting in infinite set state loop due to the event subscription for validation errors happening in checkout/block.js. As discovered in #2108, event observers cannot set context state (because the observers have no awareness of state changes and thus can be executing on stale contexts - which in turn can create this loop).

As a result, I've reconfigured the logic causing this error to react to checkout status and error state instead.

To test

I've been testing this the pull I'm doing for #2054 and verified this fixes the loop. I'm not sure how to test this other than that (the pull isn't published yet), so this could just get a code review for now and it will get more testing against payment method error creation as we start polishing that off.

@nerrad nerrad requested a review from a team as a code owner April 3, 2020 19:47
@nerrad nerrad requested review from mikejolley and Aljullu and removed request for a team April 3, 2020 19:47
@nerrad nerrad self-assigned this Apr 3, 2020
@nerrad nerrad added focus: components Work that introduces new or updates existing components. type: bug The issue/PR concerns a confirmed bug. labels Apr 3, 2020
@nerrad nerrad added this to the Future Release milestone Apr 3, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2020

Size Change: +14 B (0%)

Total Size: 2.17 MB

Filename Size Change
build/checkout-frontend.js 166 kB +6 B (0%)
build/checkout.js 80.1 kB +8 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/active-filters-frontend.js 7.52 kB 0 B
build/active-filters.js 8.29 kB 0 B
build/all-products-frontend.js 17.3 kB 0 B
build/all-products.js 66.2 kB 0 B
build/all-reviews-legacy.js 10.8 kB 0 B
build/all-reviews.js 11 kB 0 B
build/attribute-filter-frontend.js 17 kB 0 B
build/attribute-filter.js 11.8 kB 0 B
build/block-error-boundary-legacy.js 774 B 0 B
build/block-error-boundary.js 774 B 0 B
build/blocks-legacy.js 2.92 kB 0 B
build/blocks.js 2.92 kB 0 B
build/cart-frontend.js 163 kB 0 B
build/cart.js 79.4 kB 0 B
build/checkbox-control-style-legacy.js 779 B 0 B
build/checkbox-control-style.js 781 B 0 B
build/custom-select-control-style-legacy.js 782 B 0 B
build/custom-select-control-style.js 782 B 0 B
build/editor-legacy-rtl.css 12.6 kB 0 B
build/editor-legacy.css 12.6 kB 0 B
build/editor-rtl.css 13.5 kB 0 B
build/editor.css 13.5 kB 0 B
build/featured-category-legacy.js 146 kB 0 B
build/featured-category.js 146 kB 0 B
build/featured-product-legacy.js 59.5 kB 0 B
build/featured-product.js 59.4 kB 0 B
build/handpicked-products-legacy.js 7.31 kB 0 B
build/handpicked-products.js 7.51 kB 0 B
build/panel-style-legacy.js 773 B 0 B
build/panel-style.js 773 B 0 B
build/price-filter-frontend.js 14.1 kB 0 B
build/price-filter.js 10.4 kB 0 B
build/product-best-sellers-legacy.js 7.41 kB 0 B
build/product-best-sellers.js 7.62 kB 0 B
build/product-categories-legacy.js 3.2 kB 0 B
build/product-categories.js 3.19 kB 0 B
build/product-category-legacy.js 8.32 kB 0 B
build/product-category.js 8.53 kB 0 B
build/product-list-style-legacy.js 776 B 0 B
build/product-new-legacy.js 7.58 kB 0 B
build/product-new.js 7.78 kB 0 B
build/product-on-sale-legacy.js 7.92 kB 0 B
build/product-on-sale.js 8.18 kB 0 B
build/product-search-legacy.js 3.64 kB 0 B
build/product-search.js 3.86 kB 0 B
build/product-tag-legacy.js 6.48 kB 0 B
build/product-tag.js 6.68 kB 0 B
build/product-top-rated-legacy.js 7.55 kB 0 B
build/product-top-rated.js 7.75 kB 0 B
build/products-by-attribute-legacy.js 8.48 kB 0 B
build/products-by-attribute.js 8.68 kB 0 B
build/reviews-by-category-legacy.js 12.7 kB 0 B
build/reviews-by-category.js 13 kB 0 B
build/reviews-by-product-legacy.js 14.2 kB 0 B
build/reviews-by-product.js 14.5 kB 0 B
build/reviews-frontend-legacy.js 8.4 kB 0 B
build/reviews-frontend.js 9.08 kB 0 B
build/snackbar-notice-style-legacy.js 778 B 0 B
build/snackbar-notice-style.js 779 B 0 B
build/spinner-style-legacy.js 774 B 0 B
build/spinner-style.js 772 B 0 B
build/style-legacy-rtl.css 5.34 kB 0 B
build/style-legacy.css 5.35 kB 0 B
build/style-rtl.css 14.5 kB 0 B
build/style.css 14.5 kB 0 B
build/vendors-legacy.js 280 kB 0 B
build/vendors-style-legacy-rtl.css 1.97 kB 0 B
build/vendors-style-legacy.css 1.97 kB 0 B
build/vendors-style-legacy.js 110 B 0 B
build/vendors-style-rtl.css 1.97 kB 0 B
build/vendors-style.css 1.97 kB 0 B
build/vendors-style.js 108 B 0 B
build/vendors.js 367 kB 0 B
build/wc-blocks-data.js 6.71 kB 0 B
build/wc-blocks-registry.js 1.51 kB 0 B
build/wc-payment-method-cheque.js 886 B 0 B
build/wc-payment-method-stripe.js 110 kB 0 B
build/wc-settings.js 2.14 kB 0 B

compressed-size-action

Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed the same while working on #2112. 👍

I have a PR almost ready fixing that issue and there I refactor this part of the code too. I ended up hooking up this useEffect with onCheckoutProcessing. I can explain it further once I create the PR, but I wanted to point it out before approving this one.

tl;dr I'm approving this PR but I will soon create another one with some changes here as well. 🙂

@nerrad nerrad merged commit d0b182c into master Apr 4, 2020
@nerrad nerrad deleted the bug/fix-validation-state-loop branch April 4, 2020 17:36
@nerrad nerrad modified the milestones: Future Release, 2.6.0 Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: components Work that introduces new or updates existing components. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants