site-kit-wp: JavaScript error: An error occurred while running 'mapSelect': Cannot read property 'isModuleActive' of null
Bug Description
Reported in a support topic, a user encountered this error after install and navigating to the dashboard (screenshot):
An error occurred while running 'mapSelect': Cannot read property 'isModuleActive' of null
The error may be correlated with this previous error:
TypeError: Cannot read property 'isModuleActive' of null
at Object.current (https://www.socomtactical.net/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-dashboard.41176eb144adcaf84380.js:64:39347)
at e (https://www.socomtactical.net/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor.7f2f98d6cb7f1a6a3ca1.js:1:230780)
at https://www.socomtactical.net/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor.7f2f98d6cb7f1a6a3ca1.js:1:230889
at Ui (https://www.socomtactical.net/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor.7f2f98d6cb7f1a6a3ca1.js:1:538697)
at ba (https://www.socomtactical.net/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor.7f2f98d6cb7f1a6a3ca1.js:1:561620)
at t.unstable_runWithPriority (https://www.socomtactical.net/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor.7f2f98d6cb7f1a6a3ca1.js:1:581243)
at Nr (https://www.socomtactical.net/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor.7f2f98d6cb7f1a6a3ca1.js:1:506349)
at Yj (https://www.socomtactical.net/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor.7f2f98d6cb7f1a6a3ca1.js:1:558049)
at Lj (https://www.socomtactical.net/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor.7f2f98d6cb7f1a6a3ca1.js:1:548409)
at https://www.socomtactical.net/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor.7f2f98d6cb7f1a6a3ca1.js:1:506640
Original stack trace:
in PostSearcher
in FilteredComponent
in WithFilters(LegacyDashboardPopularityInner)
in LegacyDashboardPopularity
in FilteredComponent
in WithFilters(DashboardModule)
in DashboardModules
in DashboardMain
in div
in div
in div
in div
in DashboardApp
in GoogleSitekitDashboard
in RestoreSnapshots
in ErrorHandler
in Root
Additional Context
- PHP Version:
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Plugin Version [e.g. 22]
- Device: [e.g. iPhone6]
- Related support topic: https://wordpress.org/support/topic/an-error-occurred-while-running-mapselect/
- Site Health Info available
- Possible related issue: #1819
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
Test Coverage
Visual Regression Changes
QA Brief
Changelog entry
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 30
@bethanylang We discussed this in a previous internal sync, at what point it was assigned. As these minification conflicts are not specific to WP Rocket we’ve also done some internal testing for other popular plugins. Happy to triage for further team discussion.
The most recent report of this issue is now resolved, with the error appearing in this users case via the admin toolbar, as a result of WP Rocket optimisations applied.
The user defined the below exclusion to ensure the Site Kit admin toolbar is not impacted by WP Rocket optimizations (JS asset combination or minification):
/wp-content/plugins/google-site-kit/dist/assets/js/(.*).js
@bethanylang What are your thoughts on testing various popular optimisation plugins and testing admin bar functionality compatibility with the various optimizations enabled. Maybe we can come up with troubleshooting guides or exclusions.
Opened #4436 to support this, after which this issue may no longer be relevant but I suppose we’ll have to wait and see 😄
cc: @felixarntz
Reopening this as it looks like it may be possible to programmatically deactivate the minify option for WP Rocket (for logged in users), specifically using
pre_get_rocket_option_minify_js
.For additional context in order to recreate this JS error follow the steps below:
Likewise with a combination of options enabled the Site Kit tab doesn’t load. I have been able to recreate the original issue with only the minify JS option enabled in WP Rocket, all other configurations default.
Adding the below exclusion allows the Site Kit tab to operate successfully:
/wp-content/plugins/google-site-kit/dist/assets/js/(.*).js
There is a warning when these features are operated within WP Rocket.
@abdullah1908 Reassigning to you for testing WP Rocket as noted in Slack.
@tofumatt I’ve been unable to reproduce this after performing checks using various ad blockers, tests below. For those who’ve encountered this via the admin toolbar it may be related to JS minification or asset combining.
Ad Blocker Tests Complete
All checks above done on 3 different sites, all with SC, Analytics & AdSense connected with traffic. 2 of those have AdSense data, with 1 site not approved. SK main dashboard, Analytics, AdSense & Admin toolbar checked on each.
Impacted users: 2/9 unresolved. Various fixed for those who confirmed a resolution (Ad Blocker & Optimisation plugin - where the issue occurred on the front end via the admin toolbar)
I am still trying to 100% reliably reproduce this, but after looking through the issue and trying some custom adblocker scripts I think the issue is our
googlesitekit-modules-adsense.js
file.I think our public JS file
googlesitekit-modules-adsense
is likely being blocked by ad blockers, as they frequently will have rules that block all scripts containingad
oradsense
. If that file doesn’t load, it can cause the errors users are reporting.But ad blockers are always tough to diagnose because users can have custom filter sets, rules, etc. that cause it. So I’m trying to see if there are common blockers/lists/etc. that cause it. The easy solution might be to rename that file. 🙂