Skip to content

fix: stream Fragment sync siblings before async children resolve#16239

Merged
ematipico merged 4 commits intowithastro:mainfrom
dataCenter430:fix/fragment-async-streaming
Apr 7, 2026
Merged

fix: stream Fragment sync siblings before async children resolve#16239
ematipico merged 4 commits intowithastro:mainfrom
dataCenter430:fix/fragment-async-streaming

Conversation

@dataCenter430
Copy link
Copy Markdown
Contributor

Changes

  • renderFragmentComponent was calling renderSlotToString, which eagerly awaited the entire slot content into a string before returning a RenderInstance. This caused sync siblings inside a <Fragment> to block until all async children resolved, unlike <div> and bare template expressions which streamed immediately.
  • Fix: replace renderSlotToString with renderSlot, so Fragment children go through the same renderChild -> buffered async pipeline every other element uses.
  • Fixes Async Children of Fragments block earlier sibling elements from being streamed #13283

Testing

  • Added unit test in test/units/render/html-primitives.test.js verifying sync content flushes to the destination before a deferred Promise resolves.
  • Added integration tests in test/streaming.test.js using a fixture page that mirrors the issue's exact reproduction — asserts sync content arrives in an earlier stream chunk than the async child.
  • All 99 existing + new tests pass.

Docs

No docs change needed

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Apr 7, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 7, 2026

🦋 Changeset detected

Latest commit: 063ca05

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

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

@dataCenter430
Copy link
Copy Markdown
Contributor Author

Hi, @matthewp
Would you plesae review the PR when you have a chance?
Please share your feedback for this.
Thank you.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 7, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing dataCenter430:fix/fragment-async-streaming (063ca05) with main (1da523d)

Open in CodSpeed

Copy link
Copy Markdown
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Changeset is missing

@dataCenter430 dataCenter430 requested a review from ematipico April 7, 2026 12:19
@dataCenter430 dataCenter430 requested a review from ematipico April 7, 2026 15:12
@ematipico ematipico merged commit 7c65c04 into withastro:main Apr 7, 2026
24 of 26 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Async Children of Fragments block earlier sibling elements from being streamed

3 participants