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

Segment Cache Silently Swallows RSC Navigation Failures And May Commit Stale Canonical URL

When the RSC payload fetch for client-side navigation hangs or rejects, the segment-cache navigation code catches the error and returns the current state, causing the click to be permanently lost with no fallback. Additionally, a cached route entry can supply a stale canonical URL containing query parameters from a previous render, leading to the address bar committing search params the user did not request.

highConfidence 88%Next.jsAffected V16.2.6Affected V16.3.2Affected V16.4.0-Canary.4

Origin Analysis

In the segment-cache navigation logic, the promise from navigateToUnknownRoute is caught with a callback that returns the current state instead of performing a full-document fallback. This swallowed error prevents any retry or MPA navigation. The stale canonical URL issue arises because the cached Flight response includes a canonical URL that may contain query parameters from a prior render, and that cached URL is used verbatim when updating history, even if the target URL had no such search params.
1. Build a Next.js app with output: 'export' and serve the static export.\n2. Open a URL with search params (e.g., /projects?id=1&tab=estimate).\n3. Block or hang RSC payload fetches (e.g., patch window.fetch to return a pending promise for URLs containing '__next').\n4. Click a link to a different route (e.g., All Projects).\n5. Observe that nothing happens, no error is logged, and the URL remains unchanged.\n6. For the stale canonical URL symptom: with a cached route for /projects rendered with ?id=X&tab=Y, click a link to bare /projects from another page; note that the address bar changes to /projects?id=X&tab=Y.

Fixing Code Block

Edge Case Audit

The fallback to window.location.assign will cause a full page reload, which may be undesirable for purely client-side interactions and could lead to a double navigation if the original fetch eventually resolves. The sanitization of canonical URLs may break legitimate redirects or i18n routes that rely on server-provided canonical URLs differing from the requested href; test thoroughly with additional pathname features. This patch is a hotfix, not an official upstream solution; when upgrading Next.js, remove these overrides and verify that the underlying issue has been fixed to avoid conflicts with internal API changes. Rollback requires restoring the original catch block and canonical URL assignment.

Ecosystem Topology