Skip to content

fix(ssr): resolve nested async teleport content#9431

Merged
edison1105 merged 8 commits into
vuejs:mainfrom
edison1105:fix/6207
Jun 25, 2026
Merged

fix(ssr): resolve nested async teleport content#9431
edison1105 merged 8 commits into
vuejs:mainfrom
edison1105:fix/6207

Conversation

@edison1105

@edison1105 edison1105 commented Oct 19, 2023

Copy link
Copy Markdown
Member

close #6207

the root cause is that targetBuffer may be a two-dimensional array.

} else {
const { getBuffer, push } = createBuffer()
contentRenderFn(push)
push(`<!--teleport anchor-->`)
teleportContent = getBuffer()
}
targetBuffer.splice(bufferIndex, 0, teleportContent)
parentPush('<!--teleport end-->')

Summary by CodeRabbit

  • Bug Fixes
    • Improved server-side rendering for teleports that include nested Suspense and async components, ensuring correct teleport marker-only output where appropriate and correct resolved HTML placement.
    • Improved teleport buffer handling to better detect and process async teleport content during SSR.
  • Tests
    • Added coverage to verify nested async content inside Teleport + Suspense resolves correctly in renderToString.

@github-actions

github-actions Bot commented Oct 19, 2023

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 106 kB 40.2 kB 36.1 kB
vue.global.prod.js 164 kB 60.2 kB 53.5 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 48.8 kB 19 kB 17.4 kB
createApp 56.9 kB 22 kB 20.1 kB
createSSRApp 61.2 kB 23.8 kB 21.7 kB
defineCustomElement 63.1 kB 23.9 kB 21.8 kB
overall 71.7 kB 27.4 kB 25 kB

@edison1105 edison1105 added the ready for review This PR requires more reviews label Aug 1, 2024
@danielroe

Copy link
Copy Markdown
Member

this would also resolve nuxt/nuxt#35427

@edison1105 I came up with a couple of extra tests if that would be helpful in getting this merged 🙏

@edison1105

edison1105 commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

@danielroe will be merged soon.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

SSR teleport handling now marks async teleport buffers and resolves them directly. A new SSR test covers Teleport with Suspense around an async component and checks the rendered teleport output.

Changes

SSR teleport with Suspense

Layer / File(s) Summary
Async teleport buffer handling
packages/server-renderer/src/helpers/ssrRenderTeleport.ts, packages/server-renderer/src/renderToString.ts
ssrRenderTeleport marks async teleport buffers, and resolveTeleports unrolls stored buffers directly.
SSR teleport suspense regression test
packages/server-renderer/__tests__/ssrTeleport.spec.ts
The SSR teleport spec imports defineAsyncComponent and adds a test for Teleport with Suspense and an async child component.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

scope: teleport

Poem

A bunny hopped through SSR mist,
with Teleport and Suspense on the list.
Async content landed just so,
in the target where the carrots grow.
Hop! the markers stayed in sight,
and the teleported span came out right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The changes implement the reported SSR Teleport + Suspense bug by preserving async teleported content and adding coverage.
Out of Scope Changes check ✅ Passed The PR stays focused on SSR teleport/Suspense handling and adds only a targeted test plus renderer changes.
Title check ✅ Passed The title accurately reflects the main fix: SSR now resolves async content nested inside Teleport, matching the change set.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@9431
npm i https://pkg.pr.new/@vue/compiler-core@9431
yarn add https://pkg.pr.new/@vue/compiler-core@9431.tgz

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@9431
npm i https://pkg.pr.new/@vue/compiler-dom@9431
yarn add https://pkg.pr.new/@vue/compiler-dom@9431.tgz

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@9431
npm i https://pkg.pr.new/@vue/compiler-sfc@9431
yarn add https://pkg.pr.new/@vue/compiler-sfc@9431.tgz

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@9431
npm i https://pkg.pr.new/@vue/compiler-ssr@9431
yarn add https://pkg.pr.new/@vue/compiler-ssr@9431.tgz

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@9431
npm i https://pkg.pr.new/@vue/reactivity@9431
yarn add https://pkg.pr.new/@vue/reactivity@9431.tgz

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@9431
npm i https://pkg.pr.new/@vue/runtime-core@9431
yarn add https://pkg.pr.new/@vue/runtime-core@9431.tgz

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@9431
npm i https://pkg.pr.new/@vue/runtime-dom@9431
yarn add https://pkg.pr.new/@vue/runtime-dom@9431.tgz

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@9431
npm i https://pkg.pr.new/@vue/server-renderer@9431
yarn add https://pkg.pr.new/@vue/server-renderer@9431.tgz

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@9431
npm i https://pkg.pr.new/@vue/shared@9431
yarn add https://pkg.pr.new/@vue/shared@9431.tgz

vue

pnpm add https://pkg.pr.new/vue@9431
npm i https://pkg.pr.new/vue@9431
yarn add https://pkg.pr.new/vue@9431.tgz

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@9431
npm i https://pkg.pr.new/@vue/compat@9431
yarn add https://pkg.pr.new/@vue/compat@9431.tgz

commit: 68d1ee9

@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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/server-renderer/__tests__/ssrTeleport.spec.ts`:
- Around line 220-222: The teleport target assertion in ssrTeleport.spec.ts is
missing the leading `<!--teleport start anchor-->` marker. Update the expected
value in the `ssrRenderTeleport` test to match the enabled teleport wrapping
produced by `ssrRenderTeleport`, using the existing `ctx.teleports['`#target`']`
assertion as the location to fix.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0f30626d-5800-4951-aba6-fe6a84a3205f

📥 Commits

Reviewing files that changed from the base of the PR and between 325eb1d and 418985a.

📒 Files selected for processing (2)
  • packages/server-renderer/__tests__/ssrTeleport.spec.ts
  • packages/server-renderer/src/renderToString.ts

Comment thread packages/server-renderer/__tests__/ssrTeleport.spec.ts
@edison1105

Copy link
Copy Markdown
Member Author

/ecosystem-ci run

@vue-bot

vue-bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

📝 Ran ecosystem CI: Open

suite result latest scheduled
nuxt success success
primevue success success
language-tools success success
vitepress success failure
vant success success
vue-macros success success
vue-simple-compiler success failure
vueuse success success
router success success
test-utils success success
vuetify success failure
radix-vue failure failure
quasar success success
vite-plugin-vue success failure
vue-i18n success success
pinia success success

@edison1105 edison1105 changed the title fix(ssr): properly resolve suspense in teleport fix(ssr): resolve nested async teleport content Jun 25, 2026
@edison1105 edison1105 merged commit 31d0f23 into vuejs:main Jun 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSR teleports don't work with Suspense

3 participants