vercel / vercel/next.js

[Turbopack] Pages Router hydration delayed when tab opened in background

Open
#90,684 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Turbopack
Dominant language
JavaScript
Stars
142k
Forks
32.5k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/happyjosh/turbopack-pages-router-bug

To Reproduce
  1. Create minimal _app.tsx with timing logs
  2. Use yarn dev --turbopack
  3. Middle-click a link to open page in background tab
  4. Switch to the new tab and check console logs
Current vs. Expected behavior

When opening a Pages Router page in a background tab (middle-click or right-click -> open in new tab), the hydration is significantly delayed until the tab becomes visible.

Observed behavior:

  • Module loads at ~1200ms with visibilityState: hidden
  • App render happens at ~9200ms with visibilityState: visible
  • ~8 seconds delay between module load and React hydration

Expected behavior:
Hydration should complete regardless of tab visibility.

Provide environment information
- Next.js: 16.x
- React: 19.x
- Turbopack: enabled
Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context
Key Finding
  • Pages Router + Turbopack: Has this delay
  • App Router + Turbopack: Works correctly (no delay)
  • Pages Router + Webpack: Works correctly (no delay)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the linked happyjosh/turbopack-pages-router-bug reproduction with yarn dev --turbopack, beginning with its minimal _app.tsx and console timing logs. Compare Pages Router with App Router and Webpack under a background-tab load; done means Pages Router hydration completes without waiting for the tab to become visible.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js, react
Domain
build-system, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.