AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Route Announcer Crashes With `RemoveChild` After Browser Translation

AppRouterAnnouncer crashes after Chrome browser translation when the route announcement becomes empty. Chrome's translation replaces the text node, and React's `removeChild` fails because the node is no longer a child. Wrapping the announcement in a `<span key={routeAnnouncement}>` stabilizes reconciliation and avoids the crash.

highConfidence 95%Next.jsAffected V16.4.0-Canary.37

Origin Analysis

AppRouterAnnouncer renders a bare text node via `createPortal`. When the route announcement is empty (e.g., no `document.title` or `<h1>`), React attempts to remove that text node, but Chrome translation has already replaced the DOM text node with translated content, causing `NotFoundError: Failed to execute 'removeChild' on 'Node'`. The underlying design flaw is relying on direct text node identity without a stable wrapper or key in a live region that may be mutated by browser extensions.
1. Install deps, build and start: `npm install && npm run build && npm start` 2. Open http://localhost:3000 in Chrome with English (or any non-German) as the browser language. 3. Translate page from German (Use three dots next to address bar if automatic translation popup doesn't show up). 4. Click `Seite mit Titel` (`Page with title` if translated to English) 5. Click `Startseite` (`Homepage`). The client crashes with `Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.`

Fixing Code Block

Edge Case Audit

This fix may alter screen reader announcement behavior: changing the key on every announcement can cause the live region to re-announce even when content is identical? Actually key only changes if content changes. If content is same, key same, no remount. If content changes, it remounts span, potentially causing double announcement? Use with caution. Test across Chrome translation, Safari, Firefox, and screen readers. If regression occurs, rollback to the previous bare text rendering and ensure apps provide `document.title` or `<h1>` on all routes. Also consider that a `key` on a span may cause extra DOM updates for each navigation. No breaking changes to API.

Ecosystem Topology