Flight chunks read with `use()` are thrown instead of read, and Next.js hydration replaces the server DOM
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Estagnada
- Stack de tecnologia
- next.js, react, typescript
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 640
- Forks
- 32
- Merge médio
- 1h 15min
- PRs com merge (30d)
- 7
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TanStack/redact
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
TanStack/redact#195 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
TanStack/redact#142 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/redact
Issues semelhantes
-
bug data-types
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
ClickHouse/clickhouse-js#1293 ·
Mantenedores costumam responder em até 1 dia
-
area: middleware enhancement good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
agent/quality testing
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 95/100
Mantenedores costumam responder em até 1 dia
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 92/100
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
juspay/agent-distro#203 ·
Mantenedores costumam responder em até 1 dia