Skip to content

fix(ssr): hold streamed hosts until a server end marker arrives - #7052

Merged
johnjenkins merged 1 commit into
v5from
fix/v5-ssr-streaming-end-marker
Nov 26, 2026
Merged

johnjenkins merged 1 commit into
v5from
fix/v5-ssr-streaming-end-marker

Conversation

@johnjenkins

@johnjenkins johnjenkins commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What is the current behavior?

The streaming parse gate treats a host as parsed once the host, or any of its ancestors, has a next sibling. A script that appends to the document mid-stream (portals, toasts, analytics) adds such a sibling, so the host is released early. Depending on where the parser has got to, the declarative shadow root is rejected, the shadow content renders twice, or the component hydrates before its children exist.

GitHub Issue Number: #7049

What is the new behavior?

Closes #7049

  • The server writes <!--e.{hostId}--> as the last child of every hydratable host.
  • The gate holds a host until that marker arrives. Markup without one (from an older server) is held until DOMContentLoaded.
  • Hydration removes the marker, and slot collection no longer takes a nested host's marker.
  • removeHtmlComments keeps the marker.

Documentation

BREAKING_CHANGES.md: the new marker appears in renderToString() / streamToString() output.

Does this introduce a breaking change?

  • Yes
  • No

SSR output gains one comment per host. It's noted in BREAKING_CHANGES.md for anyone with SSR snapshot tests.

Testing

  • New streaming e2e tests (lazy and standalone) split the response before, inside and after a host's template while a script appends to <body>. They fail without the fix.
  • The nested-host streaming e2e test now also runs with that script.
  • Existing SSR expectations and snapshots are updated for the marker.

Other information

N/A

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.

1 participant