Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The asset "gla-gtag-events" was not registered before it was enqueued. #1659

Closed
jconroy opened this issue Aug 31, 2022 · 3 comments · Fixed by #2576
Closed

The asset "gla-gtag-events" was not registered before it was enqueued. #1659

jconroy opened this issue Aug 31, 2022 · 3 comments · Fixed by #2576
Assignees
Labels
needs investigation priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue is a confirmed bug.

Comments

@jconroy
Copy link
Member

jconroy commented Aug 31, 2022

Describe the bug:

WooFunnels.com reached out via support about https://speed-demon.com/

From version 2.1.0 updated on 2022-08-23 they started getting the following error when adding any product to the cart (using their global checkout functionality) , it shows this fatal error.

2022-08-28T00:56:35+00:00 CRITICAL Uncaught AutomatticWooCommerceGoogleListingsAndAdsExceptionInvalidAsset: The asset "gla-gtag-events" was not registered before it was enqueued. The register() method must be called during init. in /home2/speedmon/public_html/wp-content/plugins/google-listings-and-ads/src/Exception/InvalidAsset.php:24
Stack trace:
[#0](https://woothemes.zendesk.com/agent/tickets/0) /home2/speedmon/public_html/wp-content/plugins/google-listings-and-ads/src/Assets/ScriptAsset.php(119): AutomatticWooCommerceGoogleListingsAndAdsExceptionInvalidAsset::asset_not_registered('gla-gtag-events')
[#1](https://woothemes.zendesk.com/agent/tickets/1) /home2/speedmon/public_html/wp-content/plugins/google-listings-and-ads/src/Assets/BaseAsset.php(211): AutomatticWooCommerceGoogleListingsAndAdsAssetsScriptAsset->AutomatticWooCommerceGoogleListingsAndAdsAssets{closure}()
[#2](https://woothemes.zendesk.com/agent/tickets/2) /home2/speedmon/public_html/wp-content/plugins/google-listings-and-ads/src/Assets/BaseAsset.php(147): AutomatticWooCommerceGoogleListingsAndAdsAssetsBaseAsset->defer_action('wp_enqueue_scri...', Object(Closure), 10)
[#3](https://woothemes.zendesk.com/agent/tickets/3) /home2/speedmon/public_html/wp-c in /home2/speedmon/public_html/wp-content/plugins/google-listings-and-ads/src/Exception/InvalidAsset.php on line 24

Appears to be a compatibility issue (and we won't have access to the PRO plugin in use) but there might be something in the new gtag functionality we can do to better protect this issue from happening.

Steps to reproduce:

Not confirmed - based on ticket

  • Install Funnel Builder PRO
  • Set the checkout page as a global checkout
  • Do checkout by adding any product to the cart,

Expected behavior:

No critical error when add products to the cart

Actual behavior:

Critical error triggered when adding products to the cart.

Additional details:

  • n/a

5517465-zen

@jconroy jconroy added type: bug The issue is a confirmed bug. priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. needs investigation labels Aug 31, 2022
@jconroy
Copy link
Member Author

jconroy commented Aug 30, 2024

Another customer has reported a similar issue being faced with Print Invoices and Packing Lists by SkyVerge

8670391-zen

[29-Aug-2024 19:32:43 UTC] PHP Fatal error:  Uncaught Automattic\WooCommerce\GoogleListingsAndAds\Exception\InvalidAsset: The asset "gla-gtag-events" was not registered before it was enqueued. The register() method must be called during init. in /home/customer/www/mystoryblankets.com/public_html/wp-content/plugins/google-listings-and-ads/src/Exception/InvalidAsset.php:24
Stack trace:
#0 /home/customer/www/mystoryblankets.com/public_html/wp-content/plugins/google-listings-and-ads/src/Assets/ScriptAsset.php(119): Automattic\WooCommerce\GoogleListingsAndAds\Exception\InvalidAsset::asset_not_registered('gla-gtag-events')
#1 /home/customer/www/mystoryblankets.com/public_html/wp-content/plugins/google-listings-and-ads/src/Assets/BaseAsset.php(215): Automattic\WooCommerce\GoogleListingsAndAds\Assets\ScriptAsset->Automattic\WooCommerce\GoogleListingsAndAds\Assets\{closure}()
#2 /home/customer/www/mystoryblankets.com/public_html/wp-content/plugins/google-listings-and-ads/src/Assets/BaseAsset.php(148): Automattic\WooCommerce\GoogleListingsAndAds\Assets\BaseAsset->defer_action('wp_enqueue_scri...', Object(Closure), 10)
#3 /home/customer/www/mystoryblankets.com/public_html/wp-content/plugins/google-listings-and-ads/src/Assets/AssetsHandler.php(83): Automattic\WooCommerce\GoogleListingsAndAds\Assets\BaseAsset->enqueue()
#4 /home/customer/www/mystoryblankets.com/public_html/wp-content/plugins/google-listings-and-ads/src/Assets/AssetsHandler.php(55): Automattic\WooCommerce\GoogleListingsAndAds\Assets\AssetsHandler->enqueue_handle('gla-gtag-events')
#5 /home/customer/www/mystoryblankets.com/public_html/wp-content/plugins/google-listings-and-ads/src/Google/GlobalSiteTag.php(220): Automattic\WooCommerce\GoogleListingsAndAds\Assets\AssetsHandler->enqueue(Object(Automattic\WooCommerce\GoogleListingsAndAds\Assets\ScriptWithBuiltDependenciesAsset))
#6 /home/customer/www/mystoryblankets.com/public_html/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\GoogleListingsAndAds\Google\GlobalSiteTag->Automattic\WooCommerce\GoogleListingsAndAds\Google\{closure}('')
#7 /home/customer/www/mystoryblankets.com/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#8 /home/customer/www/mystoryblankets.com/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#9 /home/customer/www/mystoryblankets.com/public_html/wp-includes/general-template.php(3081): do_action('wp_footer')
#10 /home/customer/www/mystoryblankets.com/public_html/wp-content/plugins/woocommerce-pip/src/admin/class-wc-pip-customizer.php(880): wp_footer()
#11 /home/customer/www/mystoryblankets.com/public_html/wp-includes/class-wp-hook.php(324): WC_PIP_Customizer->load_template('')
#12 /home/customer/www/mystoryblankets.com/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#13 /home/customer/www/mystoryblankets.com/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#14 /home/customer/www/mystoryblankets.com/public_html/wp-includes/template-loader.php(13): do_action('template_redire...')
#15 /home/customer/www/mystoryblankets.com/public_html/wp-blog-header.php(19): require_once('/home/customer/...')
#16 /home/customer/www/mystoryblankets.com/public_html/index.php(17): require('/home/customer/...')
#17 {main}
  thrown in /home/customer/www/mystoryblankets.com/public_html/wp-content/plugins/google-listings-and-ads/src/Exception/InvalidAsset.php on line 24"

@jconroy
Copy link
Member Author

jconroy commented Aug 30, 2024

@woocommerce/automata any ideas about a possible case by case work-around we can share?

@mikkamp
Copy link
Contributor

mikkamp commented Sep 2, 2024

In this case it looks like the woocommerce-pip plugin is calling wp_footer at a very early stage, which is where we hook into to enqueue the scripts.

One solution we could explore is to catch the error and log it instead of having it halt and produce a fatal. I'm assuming in some of these cases wp_footer would still be called again later in the process. Worst case scenario is that the script won't be enqueued and the event won't be tracked, but that will be better than producing a fatal.

I'll bump this up to high so we can take a look at finding a more graceful way to handle this scenario.

We could probably test / reproduce with a test plugin that calls wp_footer as soon as it's loaded.

@mikkamp mikkamp added priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. and removed priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. labels Sep 2, 2024
@martynmjones martynmjones self-assigned this Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants