Skip to content

fix(hydration): keep lazy hydration on the async wrapper path - #14704

Merged
edison1105 merged 16 commits into
minorfrom
edison/fix/hydrationMismatch
Apr 13, 2026
Merged

edison1105 merged 16 commits into
minorfrom
edison/fix/hydrationMismatch

Conversation

@edison1105

@edison1105 edison1105 commented Apr 10, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes

    • Improved server-side rendering hydration stability for v-for, Teleport, dynamic, and async components
    • Enhanced handling of edge cases during client-side hydration including empty targets and component state transitions
    • Fixed text mismatch detection during hydration
  • Tests

    • Expanded hydration test coverage for complex component scenarios and edge cases
    • Updated test expectations for hydration behavior across framework modes

@coderabbitai

coderabbitai Bot commented Apr 10, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aa5ee5f6-f20b-4326-997d-9e83dd060100

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch edison/fix/hydrationMismatch

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented Apr 10, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@14704
npm i https://pkg.pr.new/@vue/compiler-core@14704
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@14704
npm i https://pkg.pr.new/@vue/compiler-dom@14704
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@14704
npm i https://pkg.pr.new/@vue/compiler-sfc@14704
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@14704
npm i https://pkg.pr.new/@vue/compiler-ssr@14704
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-vapor

pnpm add https://pkg.pr.new/@vue/compiler-vapor@14704
npm i https://pkg.pr.new/@vue/compiler-vapor@14704
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@14704
npm i https://pkg.pr.new/@vue/reactivity@14704
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@14704
npm i https://pkg.pr.new/@vue/runtime-core@14704
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@14704
npm i https://pkg.pr.new/@vue/runtime-dom@14704
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/runtime-vapor

pnpm add https://pkg.pr.new/@vue/runtime-vapor@14704
npm i https://pkg.pr.new/@vue/runtime-vapor@14704
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@14704
npm i https://pkg.pr.new/@vue/server-renderer@14704
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@14704
npm i https://pkg.pr.new/@vue/shared@14704
yarn add https://pkg.pr.new/@vue/[email protected]

vue

pnpm add https://pkg.pr.new/vue@14704
npm i https://pkg.pr.new/vue@14704
yarn add https://pkg.pr.new/[email protected]

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@14704
npm i https://pkg.pr.new/@vue/compat@14704
yarn add https://pkg.pr.new/@vue/[email protected]

commit: e8557fc

@github-actions

github-actions Bot commented Apr 10, 2026 •

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
compiler-dom.global.prod.js 86.4 kB 30.3 kB 26.6 kB
runtime-dom.global.prod.js 112 kB 42.3 kB 37.8 kB
vue.global.prod.js 172 kB 62.1 kB 55.3 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 51.1 kB 19.9 kB 18.2 kB
createApp 60.2 kB 23.3 kB 21.2 kB
createApp + vaporInteropPlugin 88.5 kB (+14 B) 32.5 kB (+4 B) 29.4 kB (-3 B)
createVaporApp 29 kB (+14 B) 11.2 kB (+5 B) 10.3 kB (+8 B)
createSSRApp 64.7 kB 25 kB 22.7 kB
createVaporSSRApp 34.8 kB (+2.27 kB) 13.3 kB (+718 B) 12.2 kB (+666 B)
defineCustomElement 66.7 kB 25.2 kB 22.9 kB
defineVaporCustomElement 36.3 kB (+14 B) 13.4 kB (+4 B) 12.3 kB (+12 B)
overall 75.2 kB 28.6 kB 25.9 kB

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/runtime-vapor/__tests__/hydration.spec.ts (1)

5172-5631: Avoid fixed wall-clock sleeps in the new Suspense/async hydration tests.

The setTimeout(10) / setTimeout(20) pairing makes these assertions scheduler-sensitive in CI. Prefer a manually controlled deferred promise or fake timers so each test advances exactly when the async boundary resolves.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/runtime-vapor/__tests__/hydration.spec.ts` around lines 5172 - 5631,
Tests use real setTimeout-based sleeps (new Promise(r => setTimeout(r, 10/20)))
in the Vapor tests (see vaporChildCode async setup, and the test waits after
app.mount in 'hydrate VDOM Suspense vapor async setup updates empty v-for before
trailing sibling' and similar tests). Replace these hard sleeps with a
controllable async helper: either use fake timers (vi.useFakeTimers /
vi.advanceTimersByTime) around the test or inject/return a Deferred promise from
the async setup and explicitly resolve it in the test before awaiting nextTick
so the async boundary deterministically proceeds; update all occurrences of new
Promise(r => setTimeout(r, ...)) and subsequent await new Promise(r =>
setTimeout(r, ...)) in the tests and ensure mount/wait logic (app.mount + await
nextTick) awaits the controlled resolution instead of wall-clock delays.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/runtime-vapor/__tests__/hydration.spec.ts`:
- Around line 5172-5631: Tests use real setTimeout-based sleeps (new Promise(r
=> setTimeout(r, 10/20))) in the Vapor tests (see vaporChildCode async setup,
and the test waits after app.mount in 'hydrate VDOM Suspense vapor async setup
updates empty v-for before trailing sibling' and similar tests). Replace these
hard sleeps with a controllable async helper: either use fake timers
(vi.useFakeTimers / vi.advanceTimersByTime) around the test or inject/return a
Deferred promise from the async setup and explicitly resolve it in the test
before awaiting nextTick so the async boundary deterministically proceeds;
update all occurrences of new Promise(r => setTimeout(r, ...)) and subsequent
await new Promise(r => setTimeout(r, ...)) in the tests and ensure mount/wait
logic (app.mount + await nextTick) awaits the controlled resolution instead of
wall-clock delays.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 09388716-7ad1-4f1d-8a0a-8f7feedf26cd

📥 Commits

Reviewing files that changed from the base of the PR and between 3be149e and 8475322.

📒 Files selected for processing (9)
  • packages/runtime-vapor/__tests__/hydration.spec.ts
  • packages/runtime-vapor/src/apiCreateFor.ts
  • packages/runtime-vapor/src/apiDefineAsyncComponent.ts
  • packages/runtime-vapor/src/component.ts
  • packages/runtime-vapor/src/components/Teleport.ts
  • packages/runtime-vapor/src/dom/hydration.ts
  • packages/runtime-vapor/src/dom/prop.ts
  • packages/runtime-vapor/src/fragment.ts
  • packages/vue/__tests__/e2e/hydrationStrategies.spec.ts

@edison1105 edison1105 added scope:hydration scope: vapor related to vapor mode labels Apr 10, 2026
@edison1105
edison1105 marked this pull request as ready for review April 10, 2026 01:39
@edison1105
edison1105 force-pushed the edison/fix/hydrationMismatch branch from 63eeec1 to e8557fc Compare April 13, 2026 01:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/runtime-vapor/src/component.ts (1)

850-857: Consider consolidating anchor reusability check logic.

The isReusableNullComponentAnchor function is similar to isReusableDynamicFragmentAnchor in fragment.ts (lines 535-546), but with different semantics:

  • This version: unconditionally accepts any of the 4 anchor types
  • Fragment version: matches exact label OR allows empty comment for specific labels

While functionally correct, you may want to consider either:

  1. Extracting shared logic to dom/hydration.ts
  2. Adding a comment explaining why separate implementations are needed

This is a minor maintainability suggestion and not blocking.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/runtime-vapor/src/component.ts` around lines 850 - 857, The two
functions isReusableNullComponentAnchor and isReusableDynamicFragmentAnchor
share similar anchor-check logic; either extract the common matching behavior
into a shared helper in dom/hydration.ts (e.g., a function like
matchesAnchor(node, allowedLabels, allowEmptyOnlyForLabels)) and update both
isReusableNullComponentAnchor and isReusableDynamicFragmentAnchor to call that
helper, or add a concise comment above isReusableNullComponentAnchor explaining
why its semantics must unconditionally accept empty/comment labels (contrasting
fragment behavior) so future maintainers understand the divergence.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/runtime-vapor/src/component.ts`:
- Around line 850-857: The two functions isReusableNullComponentAnchor and
isReusableDynamicFragmentAnchor share similar anchor-check logic; either extract
the common matching behavior into a shared helper in dom/hydration.ts (e.g., a
function like matchesAnchor(node, allowedLabels, allowEmptyOnlyForLabels)) and
update both isReusableNullComponentAnchor and isReusableDynamicFragmentAnchor to
call that helper, or add a concise comment above isReusableNullComponentAnchor
explaining why its semantics must unconditionally accept empty/comment labels
(contrasting fragment behavior) so future maintainers understand the divergence.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3541a6b0-fb8c-4e10-a619-33aaf7bb6f3a

📥 Commits

Reviewing files that changed from the base of the PR and between 63eeec1 and e8557fc.

📒 Files selected for processing (3)
  • packages/runtime-vapor/__tests__/hydration.spec.ts
  • packages/runtime-vapor/src/component.ts
  • packages/runtime-vapor/src/fragment.ts

@edison1105
edison1105 merged commit 1cc4870 into minor Apr 13, 2026
19 of 20 checks passed
@edison1105
edison1105 deleted the edison/fix/hydrationMismatch branch April 13, 2026 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:hydration scope: vapor related to vapor mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant