Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(react-start): keep calling use() after a hydration gate resolves - #9007

Open
pcbeingused333 wants to merge 1 commit into
TanStack:mainfrom
pcbeingused333:fix/hydrate-gate-conditional-use
Open

pcbeingused333 wants to merge 1 commit into
TanStack:mainfrom
pcbeingused333:fix/hydrate-gate-conditional-use

Conversation

@pcbeingused333

@pcbeingused333 pcbeingused333 commented Nov 27, 2026 •

Copy link
Copy Markdown

Fixes #8997

🎯 Changes

HydrationGate suspends through use() while the gate is pending but returned early once it resolved, which React 19.3 reports as a conditional use().

  • With React 19, HydrationGate now calls use() on every client render. The React 18 path (throwing the promise) is unchanged.
  • gate.resolve() marks the gate's promise as fulfilled synchronously, so use() doesn't suspend on an already resolved gate React hasn't tracked yet.

Tests cover both and fail without the change. The workspace is on React 19.2.9, which lacks this warning, so the component test asserts the use() calls rather than the console message.

A code-split route can still log the same warning from Lazy (#8487); not touched here.

This PR was prepared with AI assistance.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a React 19 warning that could occur when hydration gates resolve. Hydrated content now remains rendered without a recoverable hydration error.
    • Hydration gate promises now report their fulfilled status immediately upon resolution.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fc364ff

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@tanstack/react-start-client Patch
@tanstack/start-client-core Patch
@tanstack/react-start Patch
@tanstack/react-start-rsc Patch
@tanstack/solid-start-client Patch
@tanstack/solid-start Patch
@tanstack/start-server-core Patch
@tanstack/start-static-server-functions Patch
@tanstack/vue-start-client Patch
@tanstack/vue-start Patch
@tanstack/react-start-server Patch
@tanstack/solid-start-server Patch
@tanstack/start-plugin-core Patch
@tanstack/vue-start-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The hydration gate now marks its promise fulfilled when it resolves. When reactUse is available, HydrationGate passes the promise to it on each render. Tests cover promise status and browser hydration.

Changes: Hydration gate behavior

Layer / File(s) Summary
Set resolved gate promise status
packages/start-client-core/src/hydration/runtime.ts, packages/start-client-core/tests/hydration-runtime.test.ts
The gate sets its promise status to fulfilled and its value to undefined before calling the resolver. The test checks the status before and after resolution.
Use the gate promise on each render
packages/react-start-client/src/GenericHydrate.tsx, packages/react-start-client/src/tests/HydrateUse.test.tsx, .changeset/quiet-gates-hydrate.md
When reactUse is available, HydrationGate passes it the gate promise on each render. Without reactUse, it throws the promise only while the gate is unresolved. A browser hydration test checks that the child remains rendered and no recoverable error occurs. The changeset declares patch releases for both packages.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

  • #8487 concerns the same React 19 conditional use() warning in lazyRouteComponent and Lazy. This change addresses HydrationGate, not those code paths.

Suggested reviewers: schiller-manuel, sheraff

Merge Risk: Minimal · up to fc364

This change removes React 19's conditional use() warning in the hydration gate and leaves the React 18 behavior unchanged. No merge-blocking risk is evident. Tests cover the status marking and browser hydration.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (keep calling use() after a hydration gate resolves) and the affected area (react-start). The changeset covers exactly this: HydrationGate now calls reactUse after the gate res…
Description check Passed The description covers the change, the motivation, and the test coverage. It links issue #8997, explains the React 19 conditional use() warning, and names the two code changes. It also notes the known…
Linked Issues check Passed Issue #8997 requires that HydrationGate call use() on every client render after a suspended render, and that a resolved gate never suspend. The diff in packages/react-start-client/src/GenericHydrate.t…
Out of Scope Changes check Passed All changed files map to the linked objective. GenericHydrate.tsx contains the use() ordering change. runtime.ts contains the synchronous fulfilled-status marking. The test files cover both behaviors.…
Full details: Title check

Explanation

The title names the fix (keep calling use() after a hydration gate resolves) and the affected area (react-start). The changeset covers exactly this: HydrationGate now calls reactUse after the gate resolves, and gate.resolve() marks the promise fulfilled. The title describes the main change.

Full details: Description check

Explanation

The description covers the change, the motivation, and the test coverage. It links issue #8997, explains the React 19 conditional use() warning, and names the two code changes. It also notes the known Lazy follow-up (#8487). The Changes section uses short bullets, and the checklist and release impact sections follow the template. The third checklist item (understanding the AI-generated code) is unchecked. The description does not explicitly state the React 19.3 warning appears in a version the workspace does not use, but it does say so. The description is mostly complete.

Full details: Linked Issues check

Explanation

Issue #8997 requires that HydrationGate call use() on every client render after a suspended render, and that a resolved gate never suspend. The diff in packages/react-start-client/src/GenericHydrate.tsx now calls reactUse(props.gate.promise) whenever reactUse is available, including after resolution. The React 18 path throws the promise only while the gate is unresolved, so a resolved gate returns children. In packages/start-client-core/src/hydration/runtime.ts, gate.resolve() sets promise.status = 'fulfilled' and promise.value = undefined before resolvePromise(), so use() does not suspend on a resolved gate that React has not tracked. The PR adds tests for both behaviors (HydrateUse.test.tsx and hydration-runtime.test.ts). The #8487 Lazy warning is out of scope, as the PR description and the objectives state. Caveat: the React console warning itself was not run. The evidence is the code path and the test assertions on use() calls, which the PR states are the intended check.

Full details: Out of Scope Changes check

Explanation

All changed files map to the linked objective. GenericHydrate.tsx contains the use() ordering change. runtime.ts contains the synchronous fulfilled-status marking. The test files cover both behaviors. The changeset .changeset/quiet-gates-hydrate.md is the release note for the published packages the PR changes, as the PR description requires. No unrelated functional changes were found in the reviewed diffs of the two source files. The test file and changeset were taken from the change summary and were not inspected directly.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 10b22c2 and fc364ff.

Files selected for processing: 5

  • .changeset/quiet-gates-hydrate.md
  • packages/react-start-client/src/GenericHydrate.tsx
  • packages/react-start-client/src/tests/HydrateUse.test.tsx
  • packages/start-client-core/src/hydration/runtime.ts
  • packages/start-client-core/tests/hydration-runtime.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<Hydrate>: HydrationGate skips use() once the gate resolves, triggering React 19's "conditional use()" warning

1 participant