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

Đang mở
#89 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@mamal72 đang làm issue này rồi.

Từ ngày 27/10/2026.

  • #90 của @mamal72 — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Lĩnh vực
frontend, testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
640
Fork
32
Merge trung bình
1 giờ 15 phút
Pull request đã merge (30 ngày)
7

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TanStack/redact

Tất cả issue của TanStack/redact

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.