Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
Bug Description
There have been reports of the following error from different users.
Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
It's unknown at what stage this occurs, possible during a PageSpeed Insights test based on the title of the most recent topic. Awaiting additional information for further troubleshooting.
Support Topics (in order or occurrence - newest on top):
- https://wordpress.org/support/topic/cancelacion-de-analisis-velocidad-del-sitio/
- https://wordpress.org/support/topic/bug-312/
- https://wordpress.org/support/topic/google-site-kit-2/
- https://wordpress.org/support/topic/nao-sei-o-que-esta-acontecendo/
- https://wordpress.org/support/topic/site-toolkit-encountered-an-error/
- https://wordpress.org/support/topic/site-kit-%d0%be%d0%b1%d0%bd%d0%b0%d1%80%d1%83%d0%b6%d0%b8%d0%bb-%d0%be%d1%88%d0%b8%d0%b1%d0%ba%d1%83/
- https://wordpress.org/support/topic/%d0%bf%d0%bb%d0%b0%d0%b3%d0%b8%d0%bd-site-kit-%d0%be%d0%b1%d0%bd%d0%b0%d1%80%d1%83%d0%b6%d0%b8%d0%bb-%d0%be%d1%88%d0%b8%d0%b1%d0%ba%d1%83/
- https://wordpress.org/support/topic/site-kit-error-6/
Steps to reproduce
Assuming your browser's preferred language and site locale are set to English:
- Configure Chrome language settings (
chrome://settings/languages) to add another language

- For the added language, check the box to "Offer to translate pages in this language"
- Set up Site Kit and enable PageSpeed insights as normal
- Wait for the PageSpeed report to finish loading
- Select the "In the Lab" tab in the "Page Speed and Experience" widget on the dashboard
- Right-click on the page and select "Translate to {your chosen language}"
- Once translated, toggle the device switch on the PageSpeed Insights report (mobile <-> desktop)
- This should immediately trigger a fatal client side error and you should now see the error boundary component with the error
This is only one instance which is easily reproducible and was reported by users in the support forums, but others are possible as well.
Additional Context
- Issue first arose around SK 1.16.0
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- Site Kit interfaces should remain stable and interactive after translation by Google Translate
For more information, see https://github.com/facebook/react/issues/11538
Note: 1st party translation via i18n functions is only possible in WP 5.0+ and when translation files have been downloaded. Also, Google APIs may not support all the possible locales that WP does which may lead to some users needing to use external translation services, such as Google Translate.
Implementation Brief
This bug can be solved in slightly different ways depending on where it occurs:
- Edit
assets/js/modules/pagespeed-insights/components/common/ReportMetric.js
- Update each conditional render of the
categoryin the JSX wrapping the rendered text in aspantag. Example:{ category === CATEGORY_FAST && <span>{ _x( 'Good', 'Performance rating', 'google-site-kit' ) }</span> }
- Edit
assets/js/modules/analytics/components/common/TrackingExclusionSwitches.js
- Within the
<p>tag in the JSX, change the two conditional render statements to a single statement using inline conditional syntax ( condition ? true : false )
- Edit
Assets/js/modules/analytics/components/common/UseSnippetSwitch.js
- Within the
<p>tag in the JSX, each__( 'translate me', 'google-site-kit' )needs to be wrapped with a span tag when rendered
- Edit
assets/js/modules/tagmanager/components/common/UseSnippetSwitch.js
- Within the
<p>tag in the JSX, change the two conditional render statements to a single statement using inline conditional syntax ( condition ? true : false )
- Edit
assets/js/modules/analytics/components/dashboard/DashboardAllTrafficWidget/TotalUserCount.js
- Within the
<h3>tag wrap__( 'All Users', 'google-site-kit' )with a span tag for the cases where it is not wrapped in a Link. - Also wrap the render of
{ dimensionValue }in a<span>tag. https://github.com/google/site-kit-wp/blob/f77568c26e42dbc2f374e0a5161f72c6c43d2c21/assets/js/modules/analytics/components/dashboard/DashboardAllTrafficWidget/TotalUserCount.js#L96-L106
Here are further locations in the code where __( 'translate me', 'google-site-kit' ) needs to be wrapped with a span tag when rendered:
6. https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/components/setup/CompatibilityChecks/CompatibilityErrorNotice.js#L91-L95
7. https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/components/user-input/UserInputSelectOptions.js#L159-L163
8. https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/modules/adsense/components/settings/SettingsView.js#L134-L137
9. https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/modules/analytics/components/common/AccountCreate/index.js#L169-L172
10. https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/modules/adsense/components/setup/SetupAccountApproved.js#L97-L115
11. https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/modules/analytics/components/settings/SettingsView.js#L121-L124
12. https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/modules/analytics/components/settings/SettingsView.js#L106-L111
13. https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/modules/tagmanager/components/settings/SettingsView.js#L69-L72
14. https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/modules/tagmanager/components/settings/SettingsView.js#L81-L84
15. https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/modules/tagmanager/components/settings/SettingsView.js#L98-L101
Test Coverage
- Run Jest tests to check they all pass and update them if necessary.
Visual Regression Changes
- Run Backstop tests to check they all pass
QA Brief
- In the Pagespeed widget on the dashboard follow the 'Steps to reproduce` in the issue description above to try and generate the error in the console
- In Analytics settings, as before, translate the page to another language, click on
Editand toggle all the switches to see if they generate the error in the console - In Tag Manager settings translate the page to another language, click on
Editand toggle the switch to see if it generates the error in the console - In the Analytics widget on the dashboard, translate the page to another language. Then click on the 'Channels/Locations/Devices' tabs and slices on the piechart to see if the the error is generated in the console
- In Adsense settings translate the page to another language. Try clicking on edit and toggling the switch to see it if geneates the error in the console
- If connected, disconnect AdSense in settings. Then connect AdSense. On the step that says "Looks like you are already using AdSense" translate the page and try toggling the switch. See if the error is generated in the console
Changelog entry
- Fix javascript issues that appear when admin pages have been translated with Google Translate
@jamesozzie I am unable to replicate this at my end. Here are the tricks I applied:
- Tried with the version 1.16.0 as mentioned above
- Configured different properties
- Checked on two different hosting services(WPEngine & Bluehost )
Server Specs:
- PHP Version: 7.3.2 & 7.4.14
- WP Version: 5.5.3 & 5.6 I also searched this issue separately & I think it might be shifted to L2 so Dev team can backtrack at coding level.
One more report of this notice in the WordPress support forums, Site Kit 1.26.0, unknown at what stage this occurs.
- Unknown at what stage this occurs
- Awaiting additional info, user marked topic as "resolved" since opening
- Site title does have non standard characters
- Redirection in place to https
- One possible conflicting console error (although only from checking front end) - see below
- Content minified and assets look to be combined checking dev tools

@abdullah1908 Can I get an update on testing for this one? Thanks!
@bethanylang in the latest activity I couldn't reproduce this issue.
Thanks @abdullah1908. I'm working on writing up a clearer process for L1 > L2 escalation, but in the meantime, please tag me in an issue if you cannot reproduce so I can escalate.
@adamsilverstein Passing over to you for L2 review.
@tofumatt @aaemnnosttv @eugene-manuilov Any idea what type of problem could cause this error? From looking at the different support threads, it appears this can happen in various components/screens.
@felixarntz looks like the most consistent culprit is maybe the displayValue passed to a ReportMetric within LabReportMetrics.
I noticed that many of the reports came from non-English speakers so it may be related to this issue: https://github.com/facebook/react/issues/11538 (although not sure why it would cause a problem in that component/tree specifically more than others)
Edit: see related bug in Chrome https://bugs.chromium.org/p/chromium/issues/detail?id=872770
Edit: @felixarntz if Google Translate is the culprit here (which it seems like it may be) then I think the reason why it may happen in report metrics compared to elsewhere in the app is that we're passing the display value from the API into the component which isn't localized unlike virtually everything else. So this issue is likely specific to places in the app where we do this rather than providing a proper localized value.
Update: I was able to consistently reproduce the error here, so this has ACs now and is ready for an IB 👍
One additional report of this error. No additional insights requested.
Thanks @Hazlitte I'm glad that the solution seems to be a fairly simple one, however this issue isn't specific to the PageSpeed component (although that does seem to be where it was most commonly reported). Ideally we would solve this plugin-wide although I'm not sure there is a good solution for that.
We should at least do our best to audit where this is currently possible and fix the existing cases as there are more than just this one. This should also help us identify it preemptively in the future.
In poking around, I've also seen this possible to throw here:
- Clicking pie slices on All Traffic widget
- Toggling snippet in module settings
Let's take a few minutes and try to find any other cases to fix while we're at it.
@aaemnnosttv I used regex to search for similar code in JSX that might be susceptable to the same bug. I found 99 results in 48 files. I will update the IB to include this approach and am happy to be assigned to execute this task if you are comfortable with the approach.
@aaemnnosttv Following our discussion I successfully recreated this bug in a number of places. I also investgated other instances where the Switch component is being used as well as the date dropdown and the pie chart. There doesn't appear to be a consistent solution as the bug can be caused in slightly different ways. I have modified the IB with the 5 components which I found that need updating and reduced the estimate to a 7.
@Hazlitte I think it's important to note the condition which results in the error here. The problem manifests when an element has multiple text node/element children that render conditionally and React panics when it can't reconcile the changes made by Google Translate when trying to change what is conditionally rendered.
I think in all of these cases we have multiple children that chooses only one, much like an if/else or a switch case. The basis of the solution here is to reduce the children in JSX down to 1, or change the conditional children from text nodes to DOM elements (e.g. by wrapping with a span tag).
The IB looks pretty good for the most part, a few points to address:
Update each conditional render of the
categoryin the JSX wrapping each one in aspantag. Example:
<span>{ category === CATEGORY_FAST && _x( 'Good', 'Performance rating', 'google-site-kit' ) }</span>
This would fix the error, but it would result in 2 extra empty span tags rendered for the cases other than the category match. So in this case, we simply need to move the span to be part of the conditionally rendered output rather than outside it.
Within the
<p>tag in the JSX, change the two conditional render statements to a single statement using inline conditional syntax ( condition ? true : false )
We have generally avoided using ternary in JSX so far as it can result in blocks which are quite detached/far from the logic responsible for rendering. In this case, I think it makes sense to use but only for simple condition ? __( a ) : __( b ). Anything that starts getting into multiple lines per-case should be wrapped instead and use condition && aBlock and ! condition && bBlock. I think what you have here mostly does this anyways, but I just wanted to explain the reasoning how we should think of each going forward.
Edit
assets/js/modules/analytics/components/dashboard/DashboardAllTrafficWidget/TotalUserCount.js
- Change the conditional render of elements in the
<h3>tag to two inline conditional render syntaxes- Also wrap the render of
{ dimensionValue }in a<span>tag.
For cases like this which are a bit more complex, it would be good to include the lines for context: https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/modules/analytics/components/dashboard/DashboardAllTrafficWidget/TotalUserCount.js#L96-L106
Instead of two inline ternary conditionals, we should simply wrap __( 'All Users', 'google-site-kit' ) with a span tag for the cases where it is not wrapped in a Link. Your second point there is good though.
Also, I found another case or two that we should update (see below). Please take another look now that we have a better understanding as to what causes this specifically and see if there are any others you can find as well.
- https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/components/setup/CompatibilityChecks/CompatibilityErrorNotice.js#L91-L95
- https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/components/user-input/UserInputSelectOptions.js#L159-L163
- https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/modules/adsense/components/settings/SettingsView.js#L134-L137
- assets/js/modules/adsense/components/setup/SetupAccountApproved.js
- assets/js/modules/adsense/components/setup/SetupAccountCreate.js
- https://github.com/google/site-kit-wp/blob/4739c5c87ea9e068b0ef0c2beda4fe79e185f9e9/assets/js/modules/analytics/components/common/AccountCreate/index.js#L169-L172
@aaemnnosttv Thanks for your comments. I updated the approach in the IB and added further locations I found in the code where it appears to be susceptible to this bug.
@Hazlitte I think this is good to go now, although please fill in the sections for Test Coverage and VRT. I don't think any changes are needed here, but we should always be explicit about this.
Thanks @aaemnnosttv, I have updated the test sections.
Thanks @Hazlitte ! In this case, I don't think N/A is appropriate since these changes may result in test failures (for example if one of these components has a snapshot test), but also there should not be any visual changes as a result of these and N/A doesn't really set any expectations about how to handle that. Since both of these are technically possible given the changes we're outlining here, we should be more explicit about what to expect. Again, a failing snapshot test due to added span tags is probably fine to update, but a failing VRT test should not be ignored/approved.
IB ✅
@aaemnnosttv I have tried a few times and have not recreated this issue on the latest release with the AC's. I would like to at least see the issue in action to make sure that the QAB tests pass. Any ideas why I might not be able to recreate it?