Closed alstr closed 1 year ago
Hi @alstr - thanks for reporting this. Can you please give more detail as to your setup.
Hi, this happens with the price filter widget alone. I think other widgets may also cause it, but I stripped them all back to just that and I was still getting the error.
I can reproduce it with Twenty Twenty One (with a widget added), so I suspect it would apply to any other default theme.
I am unable to reproduce the console errors you're seeing. This is what I see with the setup you have described.
The only thing I see are some React warnings but no errors.
Strange. I just deleted all products I'd set up, to see if there was some kind of product attribute/pricing issue causing the filters to get messed up, but the error happens even on a page with no products. There's no customisation I've done to the theme or plugins, so I'm not sure why I'm getting the error but you're not. Tried it in a private browser tab too. The only thing I do notice is that the filters seem to take a while (a few seconds) to load. I also don't get the error on every page load. Sometimes it's like 1/10 times, but then often I get it a few times in a row.
@alstr I've also tested and I can't see the warnings. I've tested with WC Blocks Version: ✔ 9.6.6. Would you mind updating to the latest version to see if it's happening again?
On the page are you using the shortcode All products or the block version?
I am using the same version as you.
The sidebar uses the price filter widget block. The page itself is just the default store homepage, I've not even changed it.
The error seems to happen on any page with a sidebar. So even on product pages and misc. other pages, where the price filter gets hidden, it still causes the errors.
One thing I did notice, on another store with the same version of WordPress and WooCommerce, and using a sidebar with a price widget, I wasn't getting any errors. But I'm very confused why I'm getting them on this one, when there's nothing I've really changed.
Hello @alstr,
I tried to reproduce this issue, but also failed. Both on an existing and on a fresh site, I'm unable to see the issue that you reported. I've tried to reproduce this case with the following settings:
As for Gutenberg and WooCommerce Blocks, I tried reproducing the issue both using only WooCommerce and using WooCommerce with Gutenberg and WooCommerce Blocks.
Can you reproduce the issue when creating a fresh site on your end? I'll also ask my colleagues if any of them can reproduce this issue.
I have two stores running the same version of WordPress and WooCommerce, both set up with a single price filter widget. One is producing the error and one isn't. The one that isn't producing the error doesn't include wc-blocks-middleware.js
in the scripts loaded, which is where a lot of the problems are coming from. That seems to be a key difference. Just wondering why that might be the case. I will look into creating a fresh site to see what that's like.
@alstr As we're unable to reproduce this issue on our end, can you please send me example responses from your server when this error appears? That way we can check if the header of the response contains anything unexpected or malformed data.
I'm just using localhost at the moment whilst I'm still developing the site. What info exactly do you need and where can I get it? Thanks.
Still a bit confused as to why one site (the perfectly functioning one) isn't including wc-blocks-middleware.js
...?
Noticed a new error on every page load when I'm not logged in to the site. It doesn't seem to be directly related to the other errors but it does seem to be complaining about an API route, which one of the other errors was kind of doing. Never noticed this before.
Uncaught (in promise)
Object { code: "rest_not_logged_in", message: "You are not currently logged in.", data: {…} }
I've just reinstalled WooCommerce on the affected store and it hasn't made a difference, so corrupted files aren't to blame.
Hi @alstr Can you replace the blocks extension with this woocommerce-gutenberg-products-block.zip
And provide the console output (if any)? If there isn't any output on the console, is functionality preserved?
Also, a long shot, can you try reinstalling your server (in this case apache) with default settings, or (if this is running locally) running the application in a docker container (you can use wordpress:php8.0 for example). Does the error persist in that case?
Hey @wavvves, thanks for the reply.
When I replaced it (removing the previous blocks extension), I couldn't load up the site due to a critical error:
Warning: require_once(/Applications/MAMP/htdocs/mysite/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/deprecated.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/mysite/wp-content/plugins/woocommerce/vendor/jetpack-autoloader/class-version-loader.php on line 89
Fatal error: require_once(): Failed opening required '/Applications/MAMP/htdocs/mysite/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/deprecated.php' (include_path='.:/Applications/MAMP/bin/php/php7.4.12/lib/php') in /Applications/MAMP/htdocs/mysite/wp-content/plugins/woocommerce/vendor/jetpack-autoloader/class-version-loader.php on line 89
Notice: Function is_embed was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /Applications/MAMP/htdocs/mysite/wp-includes/functions.php on line 5865
Notice: Function is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /Applications/MAMP/htdocs/mysite/wp-includes/functions.php on line 5865
I'm not sure why.
Interestingly, when I kept the old blocks extension and added the one you provided alongside it, I'm not seeing any errors so far (or any other notable output). Bit early to say for sure, but I've just refreshed the page 10 times and I haven't had one console error, whereas normally there'd have been a couple at least.
I wonder why that is? The filters do take a good 5 seconds to fully appear after the page loads, but maybe that's because of the number of items.
I'll look at reinstalling if this doesn't lead anywhere, but at least there seems to be some modest progress.
Indeed that is weird.
when I kept the old blocks extension
On the status you provided it shows only WooCommerce as the active plugin, did you add WooCommerce Blocks separately after?
Does the error displays with it activated or only WooCommerce?
Our extension is bundled with WooCommerce so you don't need to install it separately, (mind that the feature plugin is always more up to date than the core version).
The last error you sent shows something wrong about loading the core version, did you install WooCommerce by searching for it on the backoffice, or are you using a different version? Can you try deleting the WooCommerce plugin and re-add it from the backoffice?
The zip version I sent you is a dev version, and without some constants I forgot to mention set, it will default by loading the version shipped in core. That was may have been accidentaly helpful since we now see an underlying problem with the core version.
WooCommerce blocks has always been active AFAIK, but it has just been the version that's bundled with WooCommerce (in the packages
folder; I added the new version in the same place). Do I need to modify the new version?
The error displays only when the filters are active and visible; so only when blocks are active. I can trigger it with just the price slider filter. Remove that and the errors stop.
I'm not sure what you mean by backoffice, sorry, but I originally downloaded WooCommerce via the WP admin dashboard, then replaced it with a version I'd downloaded separately. No amount of changing the WooCommerce installation seems to make a difference.
Update: I realised the download you provided was meant to go in plugins
rather than packages
, and when I did that the errors returned, so looks like nothing has changed by using the development version of blocks. It did weirdly stop all errors for a while when it was in packages
, but after updating WC and trying that again the errors are back.
Another update: I created a brand new store with a new database table. Installed WordPress, WooCommerce and Storefront. The only thing I did was add a price filter to the sidebar and I got the error immediately in Firefox. I hadn't even added products yet. This looks like something beyond my control in that case.
Weird. Let's try something again, on that new installation, on the admin, delete the Woocommerce Blocks and go to add new
> upload zip
and install and activate the zip I sent you.
Then go to WooCommerce
> status
and ensure the WooCommerce Blocks package
has awp-content/plugins
path there, to make sure we're not using the version shipped in core. If it refers to the packages
path, then add this to your wp-config.php, and check the path again:
define('JETPACK_AUTOLOAD_DEV', true);
After that, re-test your website and please past the console output 🤔
Another thing we can try; I see you are using MAMP, to rule out server config problems can you try with Local?
I have been having a similar problem with far more errors during the development of a custom Woocommerce theme, including:
front-page.php Uncaught (in promise) TypeError: can't access property "Nonce", e is undefined
single-product.php Uncaught (in promise) Error: There is no route for the given namespace (/wc/store/v1) in the store
Failed to load resource: the server responded with a status of 401 () .../:1 Uncaught (in promise) {code: 'rest_not_logged_in', message: 'You are not currently logged in.', data: {…}}
I realized that the widget sidebar I've created for the archive-product.php was loading both on the archive-product.php as well as the single-product.php page, including widgets that have no reason to exist on the single-product page (such as filters by price, attributes, etc). Even though Woocommerce wasn't loading those archive-exclusive widgets, it seems that their mere call on the single-product page causes errors when adding products to the cart. I removed them and left only widgets compatible with the single-product page (such as search and categories list) and I have been having no errors so far. I am working on creating a separate sidebar for the single-product page and checking if my register-sidebar function contains any errors.
@wavvves I made sure the dev plugin was installed correctly then tested. On first load, everything worked normally and this was the output:
After that, the errors returned:
I will have to look into the server config and test that out.
@jamesgeor My experience sounds almost identical to yours. That's an interesting observation about the type of filter and page. The errors occur for me with just the price filter on the main shop page, though.
I'm able to reproduce this when logged out, and I believe its something to do with the nonce middleware script we're importing from Gutenberg. Investigating..
Findings
preferences-persistence
package.wp-preferences-persistence-js
is a dependency of wp-preferences-js
wp-preferences-js
is a dependency. of wp-block-editor
This can only be fixed by removing the dependency on wp-block-editor
.
This is a high priority issue and logged here: https://github.com/woocommerce/woocommerce-blocks/issues/8071
I will close this in favour of https://github.com/woocommerce/woocommerce-blocks/issues/8071
Than's for the help tracing this everyone.
@mikejolley Great work Mike tracking this down!
Prerequisites
Describe the bug
I'm experiencing a number of console errors with a new WooCommerce site I'm working on.
The errors seem to stem from WooCommerce directly, the most common of which is an error in
wc-blocks-middleware.js
.I'm seeing a slightly different message in different browsers, but they seem the same. In Safari, I'm getting:
In Firefox, I'm getting (numerous times on each page load):
Sometimes I'll see this error in Firefox instead:
I've disabled every plugin bar WooCommerce, which is up to date (version 7.5.1), and reverted to the Storefront theme, with no customisation at all. WordPress is up to date, as are my browsers.
I'm at a bit of a loss as to why the errors are appearing. Sometimes they don't appear, but most of the time they do.
For the most part, the store seems to work okay, but there's the occasional hiccup, and the messages don't fill me with confidence.
Removing all sidebar widgets causes the errors to stop.
Expected behavior
No console errors.
Actual behavior
Console errors.
Steps to reproduce
WordPress Environment
WordPress address (URL): http://localhost:8888/mysite Site address (URL): http://localhost:8888/mysite WC Version: 7.5.1 REST API Version: ✔ 7.5.1 WC Blocks Version: ✔ 9.6.6 Action Scheduler Version: ✔ 3.5.4 Log Directory Writable: ✔ WP Version: 6.2 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: – WP Cron: ✔ Language: en_GB External object cache: –
Server Environment
Server Info: Apache/2.4.46 (Unix) OpenSSL/1.0.2u PHP/7.4.12 mod_wsgi/3.5 Python/2.7.13 mod_fastcgi/mod_fastcgi-SNAP-0910052141 mod_perl/2.0.11 Perl/v5.30.1 PHP Version: 7.4.12 PHP Post Max Size: 8 MB PHP Time Limit: 30 PHP Max Input Vars: 1000 cURL Version: 7.68.0 OpenSSL/1.0.2u
SUHOSIN Installed: – MySQL Version: 5.7.32 Max Upload Size: 8 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔
Database
WC Database Version: 7.5.1 WC Database Prefix: wp_ Total Database Size: 14.93MB Database Data Size: 11.26MB Database Index Size: 3.67MB wp_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_actions: Data: 1.52MB + Index: 0.66MB + Engine InnoDB wp_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_logs: Data: 0.41MB + Index: 0.31MB + Engine InnoDB wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_options: Data: 4.02MB + Index: 0.06MB + Engine InnoDB wp_postmeta: Data: 1.52MB + Index: 0.86MB + Engine InnoDB wp_posts: Data: 0.31MB + Index: 0.09MB + Engine InnoDB wp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_term_relationships: Data: 1.09MB + Index: 0.19MB + Engine InnoDB wp_term_taxonomy: Data: 0.05MB + Index: 0.03MB + Engine InnoDB wp_usermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_admin_notes: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_product_attributes_lookup: Data: 1.52MB + Index: 0.36MB + Engine InnoDB wp_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_product_meta_lookup: Data: 0.06MB + Index: 0.09MB + Engine InnoDB wp_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wpforms_tasks_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Post Type Counts
attachment: 2 customize_changeset: 11 page: 7 post: 2 product: 348 revision: 5 wpforms: 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 – 7.5.1
Inactive Plugins (4)
Jetpack: by Automattic – 11.9.1 WooCommerce Payments: by Automattic – 5.6.2 WooCommerce Shipping & Tax: by WooCommerce – 2.2.4 WPForms Lite: by WPForms – 1.8.0.2
Settings
API Enabled: – Force SSL: – Currency: GBP (£) 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: ✔ Order datastore: WC_Order_Data_Store_CPT
WC Pages
Shop base: #6 - / Basket: #7 - /basket/ Checkout: #8 - /checkout/ My account: #9 - /my-account/ Terms and conditions: ❌ Page not set
Theme
Name: Storefront Version: 4.2.0 Author URL: https://woocommerce.com/ 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: ✔
Templates
Overrides: –
Admin
Enabled Features: activity-panels analytics coupons customer-effort-score-tracks import-products-task experimental-fashion-sample-products shipping-smart-defaults shipping-setting-tour homescreen marketing multichannel-marketing mobile-app-banner navigation onboarding onboarding-tasks 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
Disabled Features: minified-js new-product-management-experience product-variation-management settings
Daily Cron: ✔ Next scheduled: 2023-03-30 14:11:06 +01:00 Options: ✔ Notes: 46 Onboarding: completed
Action Scheduler
Complete: 1,865 Oldest: 2023-03-13 14:12:20 +0000 Newest: 2023-03-30 13:22:28 +0100
Failed: 4 Oldest: 2023-03-13 15:57:15 +0000 Newest: 2023-03-28 11:58:43 +0100
Pending: 1 Oldest: 2023-03-31 13:21:50 +0100 Newest: 2023-03-31 13:21:50 +0100
Status report information
Generated at: 2023-03-30 13:35:17 +01:00
Isolating the problem