google / site-kit-wp

Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
https://sitekit.withgoogle.com
Apache License 2.0
1.23k stars 284 forks source link

Cannot read properties of null (reading '0') #4837

Closed adamdunnage closed 1 year ago

adamdunnage commented 2 years ago

Bug Description

New report of 'Cannot read properties of null (reading '0')' error message displayed in Site Kit. This has been reported twice previously with no user insights.

Recent topic: https://wordpress.org/support/topic/google-site-kit-configuration-problem-2/ Site Health: https://docs.google.com/forms/d/1lhjns2K7c0Ny7ME4gxTcsnYtNUtcMr8BvFpPQi23Y1E/edit#response=ACYDBNj60XTXxmiJSJuvu9ySD9P--oMGLlVuonUvlAMLdf5vFEecsgh7zQq9P81s-piSKbM

Previously closed topics: https://wordpress.org/support/topic/error-on-analytics-tab/ https://wordpress.org/support/topic/cannot-read-properties-of-null-reading-0/

Error message:

Cannot read properties of null (reading '0')

    in Stats
    in div
    in div
    in Widget
    in WithWidgetSlug(Widget)
    in ModuleOverviewWidget
    in WidgetRenderer
    in div
    in Cell
    in WidgetCellWrapper
    in div
    in Row
    in div
    in div
    in ForwardRef
    in WidgetAreaRenderer
    in div
    in WidgetContextRenderer
    in ModuleApp
    in GoogleSitekitModule
    in RestoreSnapshots
    in ErrorHandler
    in Root

Insights & Troubleshooting Checks performed

Steps to reproduce

Unable to reproduce so far.

Screenshots

N/A

Additional Context


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation Brief

Test Coverage

QA Brief

Changelog entry

adamdunnage commented 2 years ago

Still unable to reproduce the issue. User has responded with the following when asked for console errors and XHR response:

JQMIGRATE: Migrate is installed, version 3.3.2
admin.js?ver=1.3.2:1348 undefined undefined
googlesitekit-vendor-e20382a143485ba05084.js:7 TypeError: Cannot read properties of null (reading '0')
    at googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:21:777
    at e.exports (googlesitekit-vendor-e20382a143485ba05084.js:7:515150)
    at e.exports (googlesitekit-vendor-e20382a143485ba05084.js:7:865028)
    at v (googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:21:740)
    at h (googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:21:1107)
    at Overview (googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:58:441)
    at Ih (googlesitekit-vendor-e20382a143485ba05084.js:7:678974)
    at wi (googlesitekit-vendor-e20382a143485ba05084.js:7:724065)
    at ga (googlesitekit-vendor-e20382a143485ba05084.js:7:709669)
    at Zj (googlesitekit-vendor-e20382a143485ba05084.js:7:709594)
Pi @ googlesitekit-vendor-e20382a143485ba05084.js:7
googlesitekit-module-85767e992b6ad9b5181b.js:21 Caught an error: TypeError: Cannot read properties of null (reading '0')
    at googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:21:777
    at e.exports (googlesitekit-vendor-e20382a143485ba05084.js:7:515150)
    at e.exports (googlesitekit-vendor-e20382a143485ba05084.js:7:865028)
    at v (googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:21:740)
    at h (googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:21:1107)
    at Overview (googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:58:441)
    at Ih (googlesitekit-vendor-e20382a143485ba05084.js:7:678974)
    at wi (googlesitekit-vendor-e20382a143485ba05084.js:7:724065)
    at ga (googlesitekit-vendor-e20382a143485ba05084.js:7:709669)
    at Zj (googlesitekit-vendor-e20382a143485ba05084.js:7:709594) Object
value @ googlesitekit-module-85767e992b6ad9b5181b.js:21
googlesitekit-vendor-e20382a143485ba05084.js:7 TypeError: Cannot read properties of null (reading '0')
    at googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:17:1316
    at Array.forEach (<anonymous>)
    at p (googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:17:1270)
    at Stats (googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:58:2328)
    at Ih (googlesitekit-vendor-e20382a143485ba05084.js:7:678974)
    at wi (googlesitekit-vendor-e20382a143485ba05084.js:7:724065)
    at ga (googlesitekit-vendor-e20382a143485ba05084.js:7:709669)
    at Zj (googlesitekit-vendor-e20382a143485ba05084.js:7:709594)
    at Lj (googlesitekit-vendor-e20382a143485ba05084.js:7:706940)
    at googlesitekit-vendor-e20382a143485ba05084.js:7:665370
Pi @ googlesitekit-vendor-e20382a143485ba05084.js:7
googlesitekit-module-85767e992b6ad9b5181b.js:21 Caught an error: TypeError: Cannot read properties of null (reading '0')
    at googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:17:1316
    at Array.forEach (<anonymous>)
    at p (googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:17:1270)
    at Stats (googlesitekit-modules-search-console-7d5307b2d4c3792d6232.js:58:2328)
    at Ih (googlesitekit-vendor-e20382a143485ba05084.js:7:678974)
    at wi (googlesitekit-vendor-e20382a143485ba05084.js:7:724065)
    at ga (googlesitekit-vendor-e20382a143485ba05084.js:7:709669)
    at Zj (googlesitekit-vendor-e20382a143485ba05084.js:7:709594)
    at Lj (googlesitekit-vendor-e20382a143485ba05084.js:7:706940)
    at googlesitekit-vendor-e20382a143485ba05084.js:7:665370 Object
mxbclang commented 2 years ago

Moved to L1 per discussion with @aaemnnosttv on 22 Feb meeting.

adamdunnage commented 2 years ago

We have another recent report of this in the forum: https://wordpress.org/support/topic/site-kit-encountered-an-errorerror-request-parameter-is-empty-account/.

Here is the users Site Health: https://docs.google.com/forms/d/1lhjns2K7c0Ny7ME4gxTcsnYtNUtcMr8BvFpPQi23Y1E/edit#response=ACYDBNg3kgbFeer6_ObuugkE3S3dQ6f3tJvqWqCDMcG3WnT1FX9skvk3zqZmOHDMesn8wbA

They have also provided the following console errors:

Main page: DevTools failed to load source map: Could not load content for chrome-extension://jpdapbcmfllbpojmkefcikllfeoahglb/content_start/bundle.js.map: System error: net::ERR_BLOCKED_BY_CLIENT
DevTools failed to load source map: Could not load content for chrome-extension://jpdapbcmfllbpojmkefcikllfeoahglb/content_wrap/bundle.js.map: System error: net::ERR_BLOCKED_BY_CLIENT

Random page: Access to XMLHttpRequest at ‘https://reporting.services.disqus.com/_log/taboola?placement=%7B%22domain%22%3A%20%22https%3A%2F%2Faftercredits.com%22%2C%20%22experiment%22%3A%20%22network_default%22%2C%20%22position%22%3A%20%22bottom%22%2C%20%22shortname%22%3A%20%22aftercredits%22%2C%20%22variant%22%3A%20%22fallthrough%22%7D&is_taboola_named=true&language=en&colorscheme=light&typeface=sans-serif&variant=fallthrough&forum_id=4000480&source_url=https%3A%2F%2Faftercredits.com%2F2022%2F04%2Ffantastic-beasts-the-secrets-of-dumbledore-2022%2F&organization_id=2890836&taboola_publisher_name=disqus-network&experiment=network_default&mode=thumbnails-b&position=bottom&shortname=aftercredits&referrer_url=https%3A%2F%2Faftercredits.com%2F&canonical_url=https%3A%2F%2Faftercredits.com%2F2022%2F04%2Ffantastic-beasts-the-secrets-of-dumbledore-2022%2F&1652806660400&#8217; from origin ‘[https://aftercredits.com&#8217](https://aftercredits.com%26/#8217); has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.`
Failed to load resource: net::ERR_FAILED
soundwave.bnmla.com/usersync?sspid=1001&redirect=https%3A%2F%2Fidsync.rlcdn.com%2F396766.gif%3Fserved_by%3Devergreen%26partner_uid%3D%24UID:1 Failed to load resource: net::ERR_CERT_DATE_INVALID
DevTools failed to load source map: Could not load content for chrome-extension://jpdapbcmfllbpojmkefcikllfeoahglb/content_start/bundle.js.map: System error: net::ERR_BLOCKED_BY_CLIENT`

Site Kit page: Uncaught TypeError: jQuery(…).live is not a function
at admin.php?page=googlesitekit-dashboard:2098:33
at admin.php?page=googlesitekit-dashboard:2176:5
admin-bar-v2.js?ver=10.9-202220:3 Missing data from PHP (wpNotesArgs).
(anonymous) @ admin-bar-v2.js?ver=10.9-202220:3
/wp-json/google-site-kit/v1/modules/analytics/data/report?metrics%5B0%5D%5Bexpression%5D=ga%3Ausers&dimensions%5B0%5D%5Bname%5D=ga%3Adate&startDate=2022-04-19&endDate=2022-05-16&_locale=user:1 Failed to load resource: the server responded with a status of 400 (Bad Request)
/wp-json/google-site-kit/v1/modules/analytics/data/report?metrics%5B0%5D%5Bexpression%5D=ga%3Ausers&dimensions%5B0%5D%5Bname%5D=ga%3AchannelGrouping&startDate=2022-04-19&endDate=2022-05-16&compareStartDate=2022-03-22&compareEndDate=2022-04-18&orderby%5BfieldName%5D=ga%3Ausers&orderby%5BsortOrder%5D=DESCENDING&limit=6&_locale=user:1 Failed to load resource: the server responded with a status of 400 (Bad Request)
googlesitekit-api-d12f2d42480efa0a1f82.js:3 Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics error:”Request parameter is empty: metrics.”
(anonymous) @ googlesitekit-api-d12f2d42480efa0a1f82.js:3
/wp-json/google-site-kit/v1/modules/analytics/data/report?metrics%5B0%5D%5Bexpression%5D=ga%3Ausers&startDate=2022-04-19&endDate=2022-05-16&compareStartDate=2022-03-22&compareEndDate=2022-04-18&_locale=user:1 Failed to load resource: the server responded with a status of 400 (Bad Request)
/wp-json/google-site-kit/v1/modules/analytics/data/report?metrics%5B0%5D%5Bexpression%5D=ga%3Ausers&metrics%5B0%5D%5Balias%5D=Total%20Users&dimensions%5B0%5D%5Bname%5D=ga%3Adate&startDate=2022-04-19&endDate=2022-05-16&compareStartDate=2022-03-22&compareEndDate=2022-04-18&dimensionFilters%5Bga%3AchannelGrouping%5D=Organic%20Search&_locale=user:1 Failed to load resource: the server responded with a status of 400 (Bad Request)
/wp-json/google-site-kit/v1/modules/analytics/data/report?metrics%5B0%5D%5Bexpression%5D=ga%3AgoalCompletionsAll&metrics%5B0%5D%5Balias%5D=Goal%20Completions&metrics%5B1%5D%5Bexpression%5D=ga%3AbounceRate&dimensions%5B0%5D%5Bname%5D=ga%3Adate&startDate=2022-04-19&endDate=2022-05-16&compareStartDate=2022-03-22&compareEndDate=2022-04-18&_locale=user:1 Failed to load resource: the server responded with a status of 400 (Bad Request)
/wp-json/google-site-kit/v1/modules/analytics/data/report?metrics%5B0%5D%5Bexpression%5D=ga%3AgoalCompletionsAll&metrics%5B0%5D%5Balias%5D=Goal%20Completions&metrics%5B1%5D%5Bexpression%5D=ga%3AbounceRate&startDate=2022-04-19&endDate=2022-05-16&compareStartDate=2022-03-22&compareEndDate=2022-04-18&_locale=user:1 Failed to load resource: the server responded with a status of 400 (Bad Request)
5googlesitekit-api-d12f2d42480efa0a1f82.js:3 Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics error:”Request parameter is empty: metrics.”
(anonymous) @ googlesitekit-api-d12f2d42480efa0a1f82.js:3
googlesitekit-vendor-47a88efce259222be7fe.js:7 TypeError: Cannot read properties of null (reading ‘0’)
at googlesitekit-modules-search-console-ad2e745761e46836e186.js:21:777
at e.exports (googlesitekit-vendor-47a88efce259222be7fe.js:7:541042)
at e.exports (googlesitekit-vendor-47a88efce259222be7fe.js:7:895449)
at h (googlesitekit-modules-search-console-ad2e745761e46836e186.js:21:740)
at v (googlesitekit-modules-search-console-ad2e745761e46836e186.js:21:1107)
at Overview (googlesitekit-modules-search-console-ad2e745761e46836e186.js:58:13761)
at Ih (googlesitekit-vendor-47a88efce259222be7fe.js:7:705185)
at wi (googlesitekit-vendor-47a88efce259222be7fe.js:7:750276)
at ga (googlesitekit-vendor-47a88efce259222be7fe.js:7:735880)
at Zj (googlesitekit-vendor-47a88efce259222be7fe.js:7:735805)
Pi @ googlesitekit-vendor-47a88efce259222be7fe.js:7
googlesitekit-dashboard-7668dfed8744938a0c4b.js:21 Caught an error: TypeError: Cannot read properties of null (reading ‘0’)
at googlesitekit-modules-search-console-ad2e745761e46836e186.js:21:777
at e.exports (googlesitekit-vendor-47a88efce259222be7fe.js:7:541042)
at e.exports (googlesitekit-vendor-47a88efce259222be7fe.js:7:895449)
at h (googlesitekit-modules-search-console-ad2e745761e46836e186.js:21:740)
at v (googlesitekit-modules-search-console-ad2e745761e46836e186.js:21:1107)
at Overview (googlesitekit-modules-search-console-ad2e745761e46836e186.js:58:13761)
at Ih (googlesitekit-vendor-47a88efce259222be7fe.js:7:705185)
at wi (googlesitekit-vendor-47a88efce259222be7fe.js:7:750276)
at ga (googlesitekit-vendor-47a88efce259222be7fe.js:7:735880)
at Zj (googlesitekit-vendor-47a88efce259222be7fe.js:7:735805) Object
value @ googlesitekit-dashboard-7668dfed8744938a0c4b.js:21
googlesitekit-vendor-47a88efce259222be7fe.js:7 TypeError: Cannot read properties of null (reading ‘0’)
at googlesitekit-modules-search-console-ad2e745761e46836e186.js:17:2738
at Array.forEach (<anonymous>)
at p (googlesitekit-modules-search-console-ad2e745761e46836e186.js:17:2692)
at SearchConsoleStats (googlesitekit-modules-search-console-ad2e745761e46836e186.js:60:2997)
at Ih (googlesitekit-vendor-47a88efce259222be7fe.js:7:705185)
at wi (googlesitekit-vendor-47a88efce259222be7fe.js:7:750276)
at ga (googlesitekit-vendor-47a88efce259222be7fe.js:7:735880)
at Zj (googlesitekit-vendor-47a88efce259222be7fe.js:7:735805)
at Lj (googlesitekit-vendor-47a88efce259222be7fe.js:7:733151)
at googlesitekit-vendor-47a88efce259222be7fe.js:7:691581
Pi @ googlesitekit-vendor-47a88efce259222be7fe.js:7
googlesitekit-dashboard-7668dfed8744938a0c4b.js:21 Caught an error: TypeError: Cannot read properties of null (reading ‘0’)
at googlesitekit-modules-search-console-ad2e745761e46836e186.js:17:2738
at Array.forEach (<anonymous>)
at p (googlesitekit-modules-search-console-ad2e745761e46836e186.js:17:2692)
at SearchConsoleStats (googlesitekit-modules-search-console-ad2e745761e46836e186.js:60:2997)
at Ih (googlesitekit-vendor-47a88efce259222be7fe.js:7:705185)
at wi (googlesitekit-vendor-47a88efce259222be7fe.js:7:750276)
at ga (googlesitekit-vendor-47a88efce259222be7fe.js:7:735880)
at Zj (googlesitekit-vendor-47a88efce259222be7fe.js:7:735805)
at Lj (googlesitekit-vendor-47a88efce259222be7fe.js:7:733151)
at googlesitekit-vendor-47a88efce259222be7fe.js:7:691581 Object
value @ googlesitekit-dashboard-7668dfed8744938a0c4b.js:21
DevTools failed to load source map: Could not load content for chrome-extension://jpdapbcmfllbpojmkefcikllfeoahglb/content_start/bundle.js.map: System error: net::ERR_BLOCKED_BY_CLIENT
DevTools failed to load source map: Could not load content for chrome-extension://jpdapbcmfllbpojmkefcikllfeoahglb/content_wrap/bundle.js.map: System error: net::ERR_BLOCKED_BY_CLIENT

2. Incagnito, not logged into WordPress main page: no errors
Randome page: Access to XMLHttpRequest at ‘https://reporting.services.disqus.com/_log/taboola?placement=%7B%22domain%22%3A%20%22https%3A%2F%2Faftercredits.com%22%2C%20%22experiment%22%3A%20%22network_default%22%2C%20%22position%22%3A%20%22bottom%22%2C%20%22shortname%22%3A%20%22aftercredits%22%2C%20%22variant%22%3A%20%22fallthrough%22%7D&is_taboola_named=true&language=en&colorscheme=light&typeface=sans-serif&variant=fallthrough&forum_id=4000480&source_url=https%3A%2F%2Faftercredits.com%2F2022%2F04%2Fbad-guys-the-2022%2F&organization_id=2890836&taboola_publisher_name=disqus-network&experiment=network_default&mode=thumbnails-b&position=bottom&shortname=aftercredits&referrer_url=https%3A%2F%2Faftercredits.com%2F&canonical_url=https%3A%2F%2Faftercredits.com%2F2022%2F04%2Fbad-guys-the-2022%2F&1652806969929&#8217; from origin ‘[https://aftercredits.com&#8217](https://aftercredits.com%26/#8217); has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
reporting.services.disqus.com/_log/taboola?placement=%7B%22domain%22%3A%20%22https%3A%2F%2Faftercredits.com%22%2C%20%22experiment%22%3A%20%22network_default%22%2C%20%22position%22%3A%20%22bottom%22%2C%20%22shortname%22%3A%20%22aftercredits%22%2C%20%22variant%22%3A%20%22fallthrough%22%7D&is_taboola_named=true&language=en&colorscheme=light&typeface=sans-serif&variant=fallthrough&forum_id=4000480&source_url=https%3A%2F%2Faftercredits.com%2F2022%2F04%2Fbad-guys-the-2022%2F&organization_id=2890836&taboola_publisher_name=disqus-network&experiment=network_default&mode=thumbnails-b&position=bottom&shortname=aftercredits&referrer_url=https%3A%2F%2Faftercredits.com%2F&canonical_url=https%3A%2F%2Faftercredits.com%2F2022%2F04%2Fbad-guys-the-2022%2F&1652806969929:1 Failed to load resource: net::ERR_FAILED
common.bundle.33bc87b2c4f9324203cc85b7dd1d0492.js:7 Uncaught

So far unable to replicate but continuing to troubleshoot and work with the user so will leave any further updates if I get them.

aaemnnosttv commented 2 years ago

@adamdunnage aside from the error in the title here, this user has API errors which look odd:

Failed to load resource: the server responded with a status of 400 (Bad Request)

Which has more context in the Site Kit error Request parameter is empty: metrics., however the metrics query parameter is in the request, so it may be that something on the web server is stripping this before it reaches WP.

Maybe have the user temporarily disable WordFence or any other web firewall if they're using one to test?

adamdunnage commented 2 years ago

@aaemnnosttv The user has reported no change when disabling WordFence or any other web firewall. Could this be something happening at host level? Their setup is Ubuntu on AWS running a LEMP stack. UFW is installed, but not currently active.

aaemnnosttv commented 2 years ago

Could this be something happening at host level?

Just about anything is possible at the host level 😄 Since the site is hosted on their own AWS instance, I wouldn't expect any extra firewall type restrictions that the user didn't set up themselves.

@eugene-manuilov any ideas as to what could be going on here?

adamdunnage commented 2 years ago

@aaemnnosttv @eugene-manuilov The user has shared a screen recording of their experience. Before hitting this error message I can see that there is also a "Data error in Analytics, Request parameter is empty: metrics.".

eugene-manuilov commented 2 years ago

Could this be something happening at host level?

Just about anything is possible at the host level 😄 Since the site is hosted on their own AWS instance, I wouldn't expect any extra firewall type restrictions that the user didn't set up themselves.

@eugene-manuilov any ideas as to what could be going on here?

I do remember we had similar errors in the past and they were caused by incorrectly configured nginx server. @adamdunnage can we ask the user to provide their nginx config?

mxbclang commented 2 years ago

To close the loop here, @eugene-manuilov did not find anything obvious in the user-provided nginx config file, so we've let them know that this is likely a hosting issue but it will require deeper troubleshooting from a developer as it's not Site Kit-specific support.

Keeping this issue open for now for investigation of any future reports.

jamesozzie commented 2 years ago

We've had another report of this today. The error appears directly after successfully setting up Site Kit. The dashboard appears momentarily, before the error then appears. Further details below:

The user performed the following checks, with the issue remaining:

jamesozzie commented 2 years ago

There have been 2 more reports of this in the past week, with no further insights other than the error provided by the impacted users. Awaiting a response in both cases:

aaemnnosttv commented 2 years ago

Thanks @jamesozzie – these both indicate the error is being raised within SearchConsoleStats so I think this is worth looking into again.

jamesozzie commented 2 years ago

One user provided very useful insights into their experience with this error, including the screenshot below which shows console errors.

image

Troubleshooting ongoing, with a proposed check after disconnecting their Google account from Site Kit.

Summary of reports of this error below, starting with the most recent:

One of the users above also shared the below, which they see in their browser log: Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics error:”Request parameter is empty: metrics.”

Another user reported that the issue no longer occurs. This was after a suggestion to reset, although there was no confirmation that they performed this check. I've asked the user now.

This is not a new error. The error occurs as far back as 11 months ago, with 2 users reporting this. No insights provided from these users, and their topics were closed without a response from the user.

aaemnnosttv commented 2 years ago

I spent some time digging into this one a bit yesterday and haven't been able to figure out quite how this could happen. I was able to force the error to occur but it involved making changes to the data we get back from the API which doesn't seem like a realistic case.

Ideally we'd have a more detailed trace from the browser console as to where the error is happening as the component trace that is shown in wp.org reports only indicates in which component the error is raised within.

Regarding the screenshot above with the console error, the first error in the console translates to "No Path provides a match between the URL and the requested method." which indicates an issue at the REST API level.

A few lines that could be responsible This would require something to go wrong in `getSiteStatsDataForGoogleChart` though, but this is accessing the first element via list destructuring. https://github.com/google/site-kit-wp/blob/e77018ac25e8b05eb051338cfb2729cea1477d6f/assets/js/modules/search-console/components/dashboard/SearchFunnelWidget/SearchConsoleStats.js#L52 This gets the date from the row of the report. If `keys` should always be set though according to the [Response returned from the SC API](https://developers.google.com/webmaster-tools/v1/searchanalytics/query). https://github.com/google/site-kit-wp/blob/e77018ac25e8b05eb051338cfb2729cea1477d6f/assets/js/modules/search-console/util/site-stats-data.js#L82

So for users who see this, it would be great if they could save their console output to a file and share that to give us a little more detail as to where this is happening. This is as simple as right-clicking on the console output and choosing "Save as..." which will save the full console output as plain text.

For more power-users who are willing to try other things, we could ask them to try installing the development build of SK which would offer less-cryptic output in the event of an error because JS wouldn't be minified and "uglified". Not sure if we really want to ask users to install a different version of the plugin though.

adamdunnage commented 2 years ago

@aaemnnosttv I have the console output for one of the users experiencing this. This is the console output for the user in this support topic.

Link to console output: https://drive.google.com/file/d/1Hp1cxS_O7uPcDkDtB7bljY4AjkZphJoQ/view

Hopefully this can help you to see where in this case it may be happening. If there's anything else that might also help you with this then let me know and I can request this.

aaemnnosttv commented 2 years ago

Thanks @adamdunnage – I can see where the error is being raised in this specific case, although it isn't clear why. Looking through the log they shared, there are other errors including others that shouldn't be there under normal conditions including:

Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics error:"Parâmetro de requisição está vazio: metrics."

Request parameter is empty: metrics.

Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics error:"<h1>Erro ao estabelecer uma conexão com o banco de dados</h1>"

Error establishing a database connection

Google Site Kit API Error method:POST datapoint:survey-trigger type:core identifier:user error:"Nenhuma rota foi encontrada que corresponde com o URL e o método de requisição."

No route was found that matches the URL and request method.

These indicate to me a potentially larger problem on the site as a whole. Maybe there's a common cause here?

jamesozzie commented 1 year ago

We have another report from one user: https://wordpress.org/support/topic/an-error-occurred-while-running-mapselect-10 | SH info | Open

This impacted user reported a separate issue previously, and does have some DNS records pointing to Cloudflare servers. Disconnecting their Google account from Site Kit and connecting once more results in the same error as per this GH issue.

Update: The above topic has been closed, with no response from impacted user.

jamesozzie commented 1 year ago

Just a quick update on this one. I've reviewed all support topics so far, and not all impacted users are Nginx users, with at least one user reporting Apache.

In this latest report the user did provider some insights. They're using a self managed hosting platform, although they did indicate that they don't encounter the same error on another WordPress site on the same server (support topic | SH info)

Awaiting feedback on any REST errors and whether the same occurs if resetting SK and only connecting Search Console. On the screen where the error did appear the user reported no invalid XHR response.

jamesozzie commented 1 year ago

One user, who reported this error has shared the Nginx configurations they applied in order to resolve this. This user compared the difference in their Nginx block on a site that did connect successfully to that which encountered the error.

Old Ngix block configuration, which resulted in the error:

location / {
 try_files $uri $uri/ /index.php;
}

location /community {
 try_files  $uri $uri/ /community/index.php;
}

New Ngix block configuration, no errors:

location / {
   try_files $uri $uri/ @ee;
}
location @ee {
 rewrite ^(.*) /index.php?$1 last;
}
location /community {
  try_files  $uri $uri/ /community/index.php;
}
kuasha420 commented 1 year ago

Update on this:

I've went through all the information available in this thread and was able to reproduce the issue. However, Most of the successful reproducing involved intentionally messing with server configuration in the following steps.

  1. Misconfiguring nginx server in a way that the query params are not property passed to PHP. - This is very easy to do if an user configures the server themselves following an incomplete or missleading tutorial.
  2. Limiting the maximum accepted URL length.: - The GET:report requests with all the query parameters produces large URL strings, if the server strips the URL before it's passed to the PHP process, the error can happen. This is also likely to happen with misconfigured Nginx server.

Unfortunately, we can't do anything in plugin site to mitigate this issue since the cause of it is server specific for most cases.

There are many ways to configure nginx server for WordPress so if an user is having this issue on a nginx server they've configured, we can provide them with the minimum nginx config to compare.

# cat /etc/nginx/nginx.conf

user http;
worker_processes 1;

events {
    worker_connections 1024;
}

http {
    include           mime.types;
    default_type      application/octet-stream;
    sendfile          on;
    keepalive_timeout 65;
    gzip              on;

    server {
        # IP, SERVER NAME. ROOT ETC GOES HERE

        # This part is important
        location / {
            try_files $uri $uri/ /index.php$is_args$args;
        }

        # Or, for sites on subdirectory
        # location /wordpress {
        #     try_files $uri $uri/ /wordpress/index.php$is_args$args;
        # }

        # Handle PHP files with php-fpm
        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass            unix:/run/php-fpm7/php-fpm.sock;
            fastcgi_index           index.php;
            include                 fastcgi.conf;
        }
    }
}

Other than this, since SearchConsoleStats is known to cause this error, we can explore putting an error boundary around it. I'll file a issue for it.

Cheers.

cc @jamesozzie @aaemnnosttv @bethanylang

mxbclang commented 1 year ago

Thank you so much, @kuasha420! @jamesozzie @adamdunnage Seems like good info to add to the wiki, perhaps? I'll close this issue out, but please do let us know if you have any other questions.