woocommerce / woocommerce

A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
https://woocommerce.com
9.29k stars 10.73k forks source link

Onboarding: TypeError: Cannot read properties of undefined (reading 'is_store_country_set') #49512

Closed eliorivero closed 1 month ago

eliorivero commented 1 month ago

Prerequisites

Describe the bug

While going through the onboarding wizard for the first time in localhost, I got initially an error message in the country list saying that there was an error fetching the countries and that I should try again. When I tried again, the page reload and was replaced by this error:

Bildschirmfoto 2024-07-13 um 12 42 00

Reloading the page doesn't help. Tried opening it again in incognito and still got the same.

This is the full error: at component (http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/chunks/core-profiler.js?ver=8b1b98f78cceecbd5363:2:56827) at div at ot (http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/chunks/core-profiler.js?ver=8b1b98f78cceecbd5363:2:72838) at Suspense at U (http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:503233) at div at div at $r (http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:596219) at div at aw (http://localhost/wp/wp-includes/js/dist/components.min.js?ver=c4b2ef1c62202e4e2d1e:48:223428) at lw (http://localhost/wp/wp-includes/js/dist/components.min.js?ver=c4b2ef1c62202e4e2d1e:48:224107) at dw (http://localhost/wp/wp-includes/js/dist/components.min.js?ver=c4b2ef1c62202e4e2d1e:48:224490) at w (http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/admin-layout/index.js?ver=092d36684bd43b3c307d:1:1989) at ta (http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:596813) at ea (http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:596607) at http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:600078 at http://localhost/wp/wp-includes/js/dist/data.min.js?ver=e6595ba1a7cd34429f66:9:3282 at WithSelect(Component) (http://localhost/wp/wp-includes/js/dist/compose.min.js?ver=1339d3318cd44440dccb:9:18592) at http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:134860 at O (http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:481435) at I (http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:480876) at a (http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:475387) at http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:600331 at http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:135937 at http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:132812 at http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:132812 at http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:134034 at Ta (http://localhost/wp/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:610792)

Expected behavior

The wizard would recover and be able to continue the onboarding.

Actual behavior

Blocked in page

Oops, something went wrong We're sorry for the inconvenience. Please try reloading the page, or you can get support from the community forums.

Steps to reproduce

  1. install fresh WooCommerce (my case was in localhost)
  2. activate, you're taken to the onboarding
  3. if the country list fails, try to fetch again as suggested
  4. you get the error screen

WordPress Environment

System Status Report ``` ### WordPress Environment ### WordPress address (URL): [Redacted] Site address (URL): [Redacted] WC Version: 9.1.2 Legacy REST API Package Version: The Legacy REST API plugin is not installed on this site. Action Scheduler Version: ✔ 3.7.4 Log Directory Writable: ✔ WP Version: 6.5.5 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: – WP Cron: ✔ Language: en_US External object cache: – ### Server Environment ### Server Info: Apache/2.4.56 (Unix) PHP/8.3.9 PHP Version: 8.3.9 PHP Post Max Size: 8 MB PHP Time Limit: 30 PHP Max Input Vars: 1000 cURL Version: 8.8.0 (SecureTransport) OpenSSL/3.3.1 SUHOSIN Installed: – MySQL Version: 8.3.0 Max Upload Size: 2 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Database ### [REDACTED] ### Post Type Counts ### attachment: 1 page: 7 post: 2 wp_navigation: 1 ### Security ### Secure connection (HTTPS): ❌ Your store is not using HTTPS. Learn more about HTTPS and SSL Certificates. Hide errors from visitors: ✔ ### Active Plugins (1) ### WooCommerce: by Automattic – 9.1.2 ### Inactive Plugins (2) ### Akismet Anti-spam: Spam Protection: by Automattic - Anti-spam Team – 5.3.2 Hello Dolly: by Matt Mullenweg – 1.7.2 ### Settings ### API Enabled: – Force SSL: – Currency: USD ($) Currency Position: left Thousand Separator: , Decimal Separator: . Number of Decimals: 2 Taxonomies: Product Types: external (external) grouped (grouped) simple (simple) variable (variable) Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) exclude-from-search (exclude-from-search) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5) Connected to WooCommerce.com: – Enforce Approved Product Download Directories: ✔ HPOS feature enabled: ✔ Order datastore: Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore HPOS data sync enabled: – ### Logging ### Enabled: ✔ Handler: Automattic\WooCommerce\Internal\Admin\Logging\LogHandlerFileV2 Retention period: 30 days Level threshold: – Log directory size: 13 B ### WC Pages ### Shop base: #7 - /index.php/shop/ Cart: #8 - /index.php/cart/ - Contains the woocommerce/cart block Checkout: #9 - /index.php/checkout/ - Contains the woocommerce/checkout block My account: #10 - /index.php/my-account/ Terms and conditions: ❌ Page not set ### Theme ### Name: Twenty Twenty-Four Version: 1.1 Author URL: https://wordpress.org Child Theme: ❌ – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme WooCommerce Support: ❌ Not declared ### Templates ### Overrides: /Users/aldion/Sites/wp/wp-content/plugins/woocommerce/templates/block-notices/error.php /Users/aldion/Sites/wp/wp-content/plugins/woocommerce/templates/block-notices/notice.php /Users/aldion/Sites/wp/wp-content/plugins/woocommerce/templates/block-notices/success.php ### Admin ### Enabled Features: activity-panels analytics product-block-editor coupons core-profiler customize-store customer-effort-score-tracks import-products-task experimental-fashion-sample-products shipping-smart-defaults shipping-setting-tour homescreen marketing mobile-app-banner navigation onboarding onboarding-tasks product-custom-fields remote-inbox-notifications remote-free-extensions payment-gateway-suggestions shipping-label-banner subscriptions store-alerts transient-notices woo-mobile-welcome wc-pay-promotion wc-pay-welcome-page launch-your-store Disabled Features: experimental-blocks minified-js pattern-toolkit-full-composability product-pre-publish-modal printful settings async-product-editor-category-field product-editor-template-system Daily Cron: ✔ Next scheduled: 2024-07-14 10:36:58 +00:00 Options: ✔ Notes: 58 Onboarding: - ### Action Scheduler ### Complete: 2 Oldest: 2024-07-13 10:38:46 +0000 Newest: 2024-07-13 10:38:46 +0000 Pending: 1 Oldest: 2024-07-14 10:38:46 +0000 Newest: 2024-07-14 10:38:46 +0000 ### Status report information ### Generated at: 2024-07-13 10:49:45 +00:00 ```

Isolating the problem

moon0326 commented 1 month ago

Hi @eliorivero

Thank you for reporting the issue with details.

I've tried to reproduce it locally and on a hosting provider, but I wasn't able to reproduce it.

Do you get any request errors when you get this error by any chance?

Update: I wasn't able to reproduce "Oops, something went wrong", but I was able to reproduce the error message by blocking /wp-json/wc-analytics-data/countries endpoint.

ilyasfoo commented 1 month ago

Thanks for reporting the issue and working on the PR, @eliorivero!

@moon0326 I also was not able to reproduce the issue with WooCommerce 9.1.2, but I was able to simulate it by overriding /wp-json/wc-admin/options?options=... response content:

  1. Open developer console's network tab, filter for woocommerce_onboarding_profile
  2. Go to setup wizard
  3. Right click on the options request and click on Override content
  4. Replace the API response body to empty object {} and save
  5. Refresh onboarding wizard and observe the error screen
image
ilyasfoo commented 1 month ago

@eliorivero Appreciate if you could let us know what is the returned value in the options request as above instructions (example). This may help us figure out the root cause of the error.

kehers commented 1 month ago

I encountered the same error during setup but on checking the developer console, I noticed the request was blocked due to "mixed content", i.e. HTTPS. All I had to do was set up SSL and everything was fine.

chihsuan commented 1 month ago

@woocommerce/ghidorah 👋 I was able to reproduce it consistently by blocking all REST API requests.

https://github.com/user-attachments/assets/4ed07ee9-b24d-4eb4-9c58-88af45b0f100

It didn't show a fatal error page the first time, but after reloading the page. This is because we check the onboarding profiler option response before assigning it in the user profile step (handleOnboardingProfileOption), but we don't have that in the business info step

Also, we thought that the API failure would throw an error and could be caught by onError, but it's not the case because getOption doesn't throw an error when the API fails; it just dispatches an action that sets the error in the state.

https://github.com/woocommerce/woocommerce/blob/5f7d0cd0e12ab9a5b9c68b399ab5e792c5c6e0f5/packages/js/data/src/options/resolvers.ts#L7-L20

So, setting default values in the xstate context won't work, as the undefined value is set after the API call.

I think @eliorivero's PR would still be useful to prevent errors when the context doesn't have the expected values, but we should also update assignOnboardingProfile to handle the case where the API call fails to fix this issue.

Besides, IMO we need a follow-up issue to check all xstate code where we use getOption API as it won't throw an error when the API fails. What do you think?

ilyasfoo commented 1 month ago

Great sleuthing, @chihsuan!

I think @eliorivero's PR would still be useful to prevent errors when the context doesn't have the expected values, but we should also update assignOnboardingProfile to handle the case where the API call fails to fix this issue.

I agree. I think it's fine to have default parameters set in the component level as an additional safeguard.

Besides, IMO we need a follow-up issue to check all xstate code where we use getOption API as it won't throw an error when the API fails. What do you think?

Personally, I'd prefer if we can fix it in the API layer but I think it's also important to handle it in a way that UI can present the error. Follow-up to fix xstate code using getOption API still sound good to me in any case 👍

zakblacki commented 1 month ago

I have just bought a new web hosting ultahost.com and my SSL is active https linked with CDN cloudflare

I have the same problem ! here are logs please help.

TypeError: Cannot read properties of undefined (reading 'is_store_country_set') at component (https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/chunks/core-profiler.js?ver=8b1b98f78cceecbd5363:2:56827) at div at ot (https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/chunks/core-profiler.js?ver=8b1b98f78cceecbd5363:2:72838) at Suspense at U (https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:503233) at div at div at $r (https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:596219) at div at sw (https://bioteka-care.com/wp-includes/js/dist/components.min.js?ver=36b97398bf090476214e:34:226008) at lw (https://bioteka-care.com/wp-includes/js/dist/components.min.js?ver=36b97398bf090476214e:34:226686) at dw (https://bioteka-care.com/wp-includes/js/dist/components.min.js?ver=36b97398bf090476214e:34:227033) at w (https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/admin-layout/index.js?ver=092d36684bd43b3c307d:1:1989) at ta (https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:596813) at ea (https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:596607) at https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:600078 at https://bioteka-care.com/wp-includes/js/dist/data.min.js?ver=7c62e39de0308c73d50c:9:3292 at WithSelect(Component) (https://bioteka-care.com/wp-includes/js/dist/compose.min.js?ver=b8d54449305350b51869:9:18934) at https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:134860 at O (https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:481435) at I (https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:480876) at a (https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:475387) at https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:600331 at https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:135937 at https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:132812 at https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:132812 at https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:134034 at Ta (https://bioteka-care.com/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:610792)

zakblacki commented 1 month ago

Update : upon checking console I got the following error

[Error] Failed to load resource: the server responded with a status of 403 () (me, line 0)[Error] Unhandled Promise Rejection: [object Object]

[Error] Failed to load resource: the server responded with a status of 500 () (active, line 0)

Upon visiting the links I get either forbidden or 500 Internal Server ErrorAn internal server error has occured.

Edit : it's solved, issue was on .htacess blocking it. I had to reset it.

image
chihsuan commented 1 month ago

@zakblacki I'm glad you were able to solve the issue. Thanks for sharing the details. That would be helpful for others who might face a similar issue! 🙏

If you see any other bugs, feel free to contact us. 🙂

ConnorSmith-Dev commented 1 month ago

Exact same thing here.

`TypeError: Cannot read properties of undefined (reading 'is_store_country_set')

at component (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/chunks/core-profiler.js?ver=8b1b98f78cceecbd5363:2:56827)
at div
at ot (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/chunks/core-profiler.js?ver=8b1b98f78cceecbd5363:2:72838)
at Suspense
at U (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:503233)
at div
at div
at $r (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:596219)
at div
at sw (https://clownfocus.com.au/wp-includes/js/dist/components.min.js?ver=36b97398bf090476214e:34:226008)
at lw (https://clownfocus.com.au/wp-includes/js/dist/components.min.js?ver=36b97398bf090476214e:34:226686)
at dw (https://clownfocus.com.au/wp-includes/js/dist/components.min.js?ver=36b97398bf090476214e:34:227033)
at w (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/admin-layout/index.js?ver=092d36684bd43b3c307d:1:1989)
at ta (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:596813)
at ea (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:596607)
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:600078
at https://clownfocus.com.au/wp-includes/js/dist/data.min.js?ver=7c62e39de0308c73d50c:9:3292
at WithSelect(Component) (https://clownfocus.com.au/wp-includes/js/dist/compose.min.js?ver=b8d54449305350b51869:9:18934)
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:134860
at O (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:481435)
at I (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:480876)
at a (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:475387)
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:600331
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:135937
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:132812
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:132812
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:134034
at Ta (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:610792)`
zakblacki commented 1 month ago

Exact same thing here.

`TypeError: Cannot read properties of undefined (reading 'is_store_country_set')

at component (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/chunks/core-profiler.js?ver=8b1b98f78cceecbd5363:2:56827)
at div
at ot (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/chunks/core-profiler.js?ver=8b1b98f78cceecbd5363:2:72838)
at Suspense
at U (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:503233)
at div
at div
at $r (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:596219)
at div
at sw (https://clownfocus.com.au/wp-includes/js/dist/components.min.js?ver=36b97398bf090476214e:34:226008)
at lw (https://clownfocus.com.au/wp-includes/js/dist/components.min.js?ver=36b97398bf090476214e:34:226686)
at dw (https://clownfocus.com.au/wp-includes/js/dist/components.min.js?ver=36b97398bf090476214e:34:227033)
at w (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/admin-layout/index.js?ver=092d36684bd43b3c307d:1:1989)
at ta (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:596813)
at ea (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:596607)
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:600078
at https://clownfocus.com.au/wp-includes/js/dist/data.min.js?ver=7c62e39de0308c73d50c:9:3292
at WithSelect(Component) (https://clownfocus.com.au/wp-includes/js/dist/compose.min.js?ver=b8d54449305350b51869:9:18934)
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:134860
at O (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:481435)
at I (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:480876)
at a (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:475387)
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:600331
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:135937
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:132812
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:132812
at https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/data/index.js?ver=aa40c2f62790f4f2caac:2:134034
at Ta (https://clownfocus.com.au/wp-content/plugins/woocommerce/assets/client/admin/app/index.js?ver=8842ca4927e84b930842:2:610792)`

Check console errors and paste maybe something is blocking permission

chihsuan commented 1 month ago

Hey @zakblacki Can you please check the network tab in the browser console and see if there are any errors? That might give you a clue as to what's going wrong. Usually, this error is due to API calls failing.

thegulshankumar commented 4 weeks ago

I faced this issue at subdirectory and solved it by changing the default permalinks structure to /%postname%/

AngeloZou commented 1 week ago

I have the same problem. Wordpress Version 6.6.1, Woocommerce Version 9.1.4.

Screenshot_3 Screenshot_4