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

Layout Redirect During Client Navigation Causes Repeated ?_Rsc Requests And Blank Page

Next.js App Router client-side Link navigation to a route whose shared layout calls redirect triggers infinite RSC fetch loop; direct destination navigation works. Reproduced on Next 15.1.7 through 16.4.0-canary.57 with both webpack and Turbopack.

highConfidence 75%Next.jsHydrationReact Server ComponentsPages RouterAffected V15.1.7Affected V16.3.8Affected V16.4.0-Canary.57

Origin Analysis

The App Router's client navigation incorrectly retains the redirect result from the shared layout's server component fetch. When the initial RSC request for /test receives a redirect to /test/1/1, the router follows it, but the subsequent RSC request for /test/1/1 incorrectly inherits or replays the same redirect flag/cache entry instead of rendering the target layout/page. This causes an infinite loop of fetching the target RSC payload while never committing the UI.
1. Clone https://github.com/heecheon92/nextjs-redirect-bug at commit 9b397509ac86f03e2557d916ca6482d4e1010851. 2. Run `npm ci` and `npm run dev` (Next 15.1.7). 3. Open `/` and click 'Enter the evil loop'. Observe blank page at `/test/1/1` and repeated `/test/1/1?_rsc=...` requests. 4. Directly opening `/test/1/1` succeeds. 5. Stop dev, run `npm run build && npm run start`, click link again: production also loops.

Fixing Code Block

Edge Case Audit

This workaround relies on Edge Middleware being available in your deployment environment. If your platform does not support middleware, or if the redirect depends on data fetched in the layout (not available in middleware), this may not apply. Ensure the matcher only targets the intended /test route to avoid unintended redirects. Test both direct and client navigations after applying. Rollback: revert middleware.ts to the previous header-only version and restore the layout redirect. Note: middleware redirect uses 307; use 308 if the redirect is permanent to avoid SEO/caching implications.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state