Flight chunks read with `use()` are thrown instead of read, and Next.js hydration replaces the server DOM

Aperta
#89 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@mamal72 ci sta già lavorando.

Dal 27/10/2026.

  • #90 di @mamal72 — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
next.js, react, typescript
Ambito
frontend, testing

Direzione di ricerca

Read src/react/thenable.ts and compare its handling of unsettled chunks with the trackUsedThenable behavior described in the issue. Reproduce using the examples/next-demo production build with and without NEXT_TEST_REFERENCE=1; verify that the server-rendered paragraph remains during hydration and no mismatch is reported. Related issue #82 covers genuinely pending promises.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version: @tanstack/redact 0.2.1 via withRedact, Next.js 16.4.3 (App Router, Turbopack, production), react/react-dom 19.3.1, Chromium. Unchanged on main (20f6dd6).

What happens

A Server Component passes a promise to a Client Component, which reads it with use(). During hydration, Redact reports Hydration mismatch. and replaces the server-rendered element, even though the content matches. React 19.3.1 hydrates the same page with no errors and keeps the server node.

Repro

// app/flight-promise/page.jsx
import Reader from './reader'
export default function Page() {
  return <main><Reader value={Promise.resolve('Read from the server')} /></main>
}

// app/flight-promise/reader.jsx
'use client'
import { use } from 'react'
export default function Reader({ value }) {
  return <p id="read">{use(value)}</p>
}

Comparing the same page in examples/next-demo (next build && next start, with and without NEXT_TEST_REFERENCE=1):

React 19.3.1 Redact 0.2.1
Server <p id="read"> kept yes no, replaced
pageerror none Hydration mismatch.

Impact

In a larger App Router app, the same promises are also thrown as bare values ({status: "resolved_model", value: null} and {status: "blocked", …}) instead of being read. Client interactions in the affected tree stop working, including dialogs opened from search params, search and locale switching.

Where

src/react/thenable.ts subscribes only when status === undefined. React's Flight client gives its chunks a status of their own (resolved_model, blocked, …), and they only initialize or settle once something calls .then(). React's trackUsedThenable subscribes to any unsettled thenable and then checks again, so a resolved_model chunk is read in the same pass. Redact throws it instead.

Related: #82. Once Redact suspends on such a chunk during hydration without a <Suspense> directly above it, the mismatch comes from the path described there. The PR for this issue avoids suspending on chunks that are already resolved, as React does; #82 still applies to promises that are really pending.

Lingua principale
TypeScript
Stelle
640
Fork
32
Merge medio
1h 15m
PR unite (30g)
7

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TanStack/redact

Tutte le issue di TanStack/redact

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.