feat: out-of-order streaming SSR for Suspense#4031
Draft
Madoshakalaka wants to merge 5 commits intomasterfrom
Draft
feat: out-of-order streaming SSR for Suspense#4031Madoshakalaka wants to merge 5 commits intomasterfrom
Madoshakalaka wants to merge 5 commits intomasterfrom
Conversation
When a component inside a <Suspense> boundary suspends during SSR, emit the fallback immediately and append the resolved content at the end of the stream with an inline script that swaps it into place. This avoids blocking the entire HTTP response on slow async operations. - Add SsrContext to track deferred suspense boundaries - Poll children once in VSuspense::render_into_stream; if Pending, stream fallback with boundary markers and spawn deferred rendering - Flush deferred content with $YC swap script after main tree completes - Thread SsrContext through all render_into_stream methods - Add suspense_ssr example demonstrating the feature
|
Visit the preview URL for this PR (updated for commit 45a31f1): https://yew-rs--pr4031-feat-ssr-out-of-orde-n7rapk68.web.app (expires Mon, 09 Mar 2026 12:58:46 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Benchmark - coreYew MasterPull Request |
Size ComparisonDetails
✅ None of the examples has changed their size significantly. |
Benchmark - SSRYew MasterDetails
Pull RequestDetails
|
In browser WASM, the scheduler defers via spawn_local, so poll!() always returns Pending regardless of whether children truly suspend. This caused hydration integration tests to fail because non-suspending components were incorrectly rendered with fallback+deferred format. Out-of-order streaming now only activates on native/WASI targets where the scheduler is synchronous. On WASM-browser, the old inline rendering behavior is preserved.
this aligns with our template repo and works on both the frontend and backend
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
We now stream suspense fallback UI immediately during SSR. So long running data-fetching won't bottleneck the page.
Before: the entire response blocks until fetch_from_database() completes.
After:
<h1>, the fallback<p>Loading...</p>, and<footer>stream immediately. The resolved<div>swaps in when the fetch finishes.Resolves #3619
Checklist