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

Runtime Prefetch Runs For Every Dynamic Render, And A Prefetch Export Cannot Opt A Route Out

When global partialPrefetching is enabled, routes that export prefetch = 'force-disabled' (or 'auto') still spawn a runtime prefetch shell for every dynamic render, causing unnecessary server cost and duplicate payload. The segment-level export should be able to opt out of the global default.

highConfidence 93%Next.jsHydrationTurbopackAffected V16.3.1

Origin Analysis

The condition in server/app-render/app-render.js (lines 475 and 2003) is `if (Boolean(renderOpts.partialPrefetching) || await anySegmentHasPartialPrefetchingEnabled(tree))`. Because the first operand short-circuits when the global flag is true, the code never checks whether the route's segment configuration explicitly disables runtime prefetch. The function `anySegmentHasPartialPrefetchingEnabled` only detects opt-in values ('partial', 'unstable_eager'), so an opt-out cannot be expressed.
1. Clone https://github.com/damianfrizzi/next-runtime-prefetch-repro 2. Run `bun install` 3. Run `./run-all.sh` 4. Observe the output table: rows with partialPrefetching true and no opt-out have 2 copies in Flight; partialPrefetching false has 1 copy. The row with prefetch='force-disabled' still has 2 copies.

Fixing Code Block

Edge Case Audit

This change alters the conditions under which runtime prefetch is generated. Routes that previously relied on the global flag and had no explicit opt-out will continue to spawn prefetch, but routes with `prefetch='auto'` may now stop spawning if `auto` is treated as an opt-out; verify that this matches the intended semantics for auto. The new tree traversal adds a small per-render overhead. Because this is an internal Next.js patch, it is tightly coupled to app-render.js internals and may break after upgrading to a newer version; apply the same change only to the exact versions listed. Rollback: revert the two condition replacements and delete the new helper functions. Test with representative routes under partialPrefetching true, especially those using searchParams and multiple parallel routes.

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