Cannot read property 'slug' of undefined
See original GitHub issueBug Description
There have been reports of a Cannot read property 'slug' of undefined
error, first occurring from 1.34.1. Based on one users experience this occurs when accessing the primary Site Kit dashboard. No additional insights available.
https://wordpress.org/support/topic/depannage-du-tableau-de-bord-google-kit-site/ - Open - No SH info https://wordpress.org/support/topic/site-kite-error/ - Open - No SH info https://wordpress.org/support/topic/site-kit-error-8 - Open - No valid SH info (User from another topic referenced this topic) https://wordpress.org/support/topic/error-site-kit-encountered-an-error - Resolved no specific action - SH Info provided https://wordpress.org/support/topic/fix-for-site-kit-encountered-an-error/ - Resolved Closed with no response from user - No SH info https://wordpress.org/support/topic/error-in-setup-wizard/#new-topic-0 - Resolved Unknown fix - SH info provided https://wordpress.org/support/topic/site-kit-encountered-an-error-45 - Open - No SH info yet
Console error from one impacted user - since resolved without any specific action
Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
googlesitekit-vendor.346be2e029bd28ac57dd.js:1 TypeError: Cannot read property 'slug' of undefined
at p (googlesitekit-dashboard.e2fb2513a57b6894e158.js:64)
at WidgetAreaRenderer (googlesitekit-dashboard.e2fb2513a57b6894e158.js:120)
at Ih (googlesitekit-vendor.346be2e029bd28ac57dd.js:1)
at wi (googlesitekit-vendor.346be2e029bd28ac57dd.js:1)
at ga (googlesitekit-vendor.346be2e029bd28ac57dd.js:1)
at Zj (googlesitekit-vendor.346be2e029bd28ac57dd.js:1)
at Lj (googlesitekit-vendor.346be2e029bd28ac57dd.js:1)
at googlesitekit-vendor.346be2e029bd28ac57dd.js:1
at t.unstable_runWithPriority (googlesitekit-vendor.346be2e029bd28ac57dd.js:1)
at Mr (googlesitekit-vendor.346be2e029bd28ac57dd.js:1)
Pi @ googlesitekit-vendor.346be2e029bd28ac57dd.js:1
googlesitekit-dashboard.e2fb2513a57b6894e158.js:66 Caught an error: TypeError: Cannot read property 'slug' of undefined
at p (googlesitekit-dashboard.e2fb2513a57b6894e158.js:64)
at WidgetAreaRenderer (googlesitekit-dashboard.e2fb2513a57b6894e158.js:120)
at Ih (googlesitekit-vendor.346be2e029bd28ac57dd.js:1)
at wi (googlesitekit-vendor.346be2e029bd28ac57dd.js:1)
at ga (googlesitekit-vendor.346be2e029bd28ac57dd.js:1)
at Zj (googlesitekit-vendor.346be2e029bd28ac57dd.js:1)
at Lj (googlesitekit-vendor.346be2e029bd28ac57dd.js:1)
at googlesitekit-vendor.346be2e029bd28ac57dd.js:1
at t.unstable_runWithPriority (googlesitekit-vendor.346be2e029bd28ac57dd.js:1)
at Mr (googlesitekit-vendor.346be2e029bd28ac57dd.js:1) Object
value @ googlesitekit-dashboard.e2fb2513a57b6894e158.js:66
DevTools failed to load source map: Could not load content for https://*******/wp-content/plugins/log-cleaner-for-ithemes-security/css/log-cleaner.css.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
Additional Context
- Started to occur from Site Kit 1.34.1
- Possibly AMP related, with one user reporting the same in the AMP forums and captured SH info’s indicating the same.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- Rendering a widget area with no widgets should not raise any errors
Implementation Brief
- Update
combineWidgets
to return early if no widgets are given (i.e. nothing to combine) - Merge https://github.com/google/site-kit-wp/pull/3800
Test Coverage
- Tests are added to cover the changes to ensure the widget combination functions support no widgets given.
Visual Regression Changes
- No changes
QA Brief
- This one is difficult to QA and I was unable to reproduce it in the browser but it is specific to a widget area rendering with zero widgets – I’m guessing this might only be possible due to timing around when the area renders and when the widget registration happens since this is specifically zero total widgets for the area, not just active widgets.
- See the comment on the issue where this was reproduced in a test after identifying
combineWidgets
as the source of the error https://github.com/google/site-kit-wp/issues/3618#issuecomment-892488288
Changelog entry
- Fix potential “Cannot read property ‘slug’ of undefined” error on Site Kit screens.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:13 (2 by maintainers)
I was able to reproduce this error in a test, with the only condition being no widgets. Moving forward to execution as the fix is rather simple and will include this added test.
@bethanylang I think so. I’ll do a quick review and try to recreate the same environment before escalating.