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

Turbopack Pages Router Hydration Delayed When Tab Opened In Background

With Turbopack enabled, Pages Router pages defer React hydration until the browser tab becomes visible. In background tabs, hydration can be delayed by several seconds (observed ~8s), while App Router and webpack are unaffected.

highConfidence 75%Next.jsApp RouterPages RouterAffected V16.x

Origin Analysis

The Turbopack Pages Router client runtime schedules the React hydration call through a visibility-sensitive API (likely `requestIdleCallback` without a timeout or `requestAnimationFrame`). These callbacks are suspended or heavily throttled when the document is hidden, so hydration does not execute until the user switches to the tab.
1. Create a minimal `_app.tsx` with timing logs (module load and app render). 2. Run `yarn dev --turbopack`. 3. Middle-click a link to open a page in a background tab. 4. Switch to the new tab after a few seconds and observe the console logs: module load occurs while hidden, app render occurs only after the tab becomes visible.

Fixing Code Block

Edge Case Audit

Patching `requestIdleCallback` globally may cause other code that intentionally waits for true idle time to run earlier than expected, potentially increasing CPU usage in background tabs. If the underlying scheduler is `requestAnimationFrame` instead of `requestIdleCallback`, this patch will not resolve the issue. Roll back by removing the script once an official fix is available; avoid using this patch in production if battery life is critical.

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