Flight chunks read with `use()` are thrown instead of read, and Next.js hydration replaces the server DOM
I maintainer di solito rispondono entro 1 giorno
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
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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/redact
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
TanStack/redact#195 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TanStack/redact#142 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/redact
Issue simili
-
bug data-types
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
ClickHouse/clickhouse-js#1293 ·
I maintainer di solito rispondono entro 1 giorno
-
area: middleware enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
agent/quality testing
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
I maintainer di solito rispondono entro 1 giorno
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
juspay/agent-distro#203 ·
I maintainer di solito rispondono entro 1 giorno