Repository navigation
Add template for dpu support after PR #508 - #509
Open
MaxwellCohen wants to merge 28 commits into
Open
MaxwellCohen wants to merge 28 commits into
MaxwellCohen wants to merge 28 commits into
Conversation
Every Suspense boundary writes a marked range: `<!--$s=-->` around content that is in the HTML, `<!--$s?id-->` around the fallback of a boundary that is still to be streamed, `<!--$s!-->` around a fallback that is left to the client. A streamed boundary's content follows in `<preact-island hidden data-target="id">`, as before, and an empty comment. The island moves its content into the range once that comment has arrived, then tells hydration the content is there. An island cut off by the end of the response hands its range to the client. While streaming, the boundary itself catches what suspends or fails below it, so its range covers all of its children and a nested boundary is never sent before the HTML that holds its range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Browsers with Declarative Partial Updates stream a boundary's content into its range while they parse the template. The `$PRS` init script patches it in elsewhere, and does what the island did: wake the boundary, reparse SVG and MathML, drop ranges the client unmounted, and hand ranges to the client when the server gives up or the response ends. A pending range holds `<?start>`/`<?end>` around its fallback, which mark what the template replaces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5
# Conflicts: # src/lib/client.js # test/client.test.jsx
Co-Authored-By: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5
…dpu-boundary-streaming # Conflicts: # src/lib/chunked.js # src/lib/client.js
🦋 Changeset detectedLatest commit: e004fdb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
MaxwellCohen
marked this pull request as ready for review
November 22, 2026 17:53
…eaming # Conflicts: # src/lib/chunked.js # test/compat/render-chunked.test.jsx
# Conflicts: # src/lib/chunked.js
Co-Authored-By: Claude Opus 5.5
Create the comment iterator up front and find a range's closer through the marker map in one helper. Co-Authored-By: Claude Opus 5.5
# Conflicts: # src/lib/client.js
The server wraps a boundary's content in <svg> or <math> when its parent is in that namespace, so the parser creates the right elements. The init script unwraps it instead of reparsing the range. Co-Authored-By: Claude Opus 5.5
# Conflicts: # src/lib/chunked.js # src/lib/client.js # test/client.test.jsx
…andling The client now removes the range of a pending boundary it unmounts, so the script no longer needs to drop ranges marked with __w = 0. Every range still pending when the document loads becomes $s!. Co-Authored-By: Claude Opus 5.5
# Conflicts: # src/lib/client.js # test/client.test.jsx
Without reparsing, the moved nodes are the same ones the document's iterator already indexed, so the TreeWalker pass and the first-copy-wins check go. Co-Authored-By: Claude Opus 5.5
# Conflicts: # src/lib/client.js
Per-response ids starting at 0 collided when two streamed renders end up in one document. Co-Authored-By: Claude Sonnet 5.5
# Conflicts: # test/compat/recoverable.test.jsx # test/compat/render-chunked.test.jsx
The vnode id keeps boundaries apart within a process; a random prefix keeps them apart from another server's response in the same document. Base 36 keeps them short. Co-Authored-By: Claude Opus 5.5
An island now completes only once the empty comment the server writes after it arrives, so a node an extension adds after it can't make it patch half a chunk. On DOMContentLoaded the script only drops cut-off islands: compat now ends the wait for pending ranges itself. annotation-xml switches back to HTML only with an HTML encoding. Co-Authored-By: Claude Opus 5.5
Drop the DOMContentLoaded handler: compat ends the wait for pending ranges itself. Co-Authored-By: Claude Opus 5.5
$PRS took the template only from right before its script, so a node added in between (by a browser extension) left the range to the client and the template behind. Co-Authored-By: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5
This branch has not been deployed
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.
This is a stacked PR for #508.
It adds a back template for support.
This is the Preact server-side of the suspense streaming fixes. I got these fixes from using an LLM-generated streaming harness (source).
With this pr adds
<template for>steaming<preact-island>(#508)<template for>(#508 + #509)lazyFirst,multiRootClient,lazyMulti,lazyNull,realLazyNoStream,twoInOne,wrapFirstServer,lazySecond,realLazy,lazyDeep,lazyRef,wrapMidClient,serverWaterfall,lazyInDiv,textLazy,resuspend_claimhook; the boundary takes its range; a suspend goes up to the boundary; the partial render is thrown away; the server DOM stays instead of the fallback; markers are removed on commit;refQueuerollback$s=; suspensions go to the boundaryinnerPlain,outerNoRangeLazy,outerNoRange,rootBoundary,emptyPair,gateAboveNoWrap,sameTag,siblings,nest3,directNest,gateAboverangeEndfinds a range's end while a chunk is still streaming$s=opening marker; a pending range's closing marker carries its id<?start>/<?end>inside the rangehideNested,laterNested,tickProp,hideOnly,tickAttr,later$PRS()keyed,keyedComp,keyedGrow,keyedNoStreamsvgTitle,math,svgImage,svgForeign,svgserverErrorLate$s!fallback, then renders the content on the clientdata-x, or a lost template</body>splits the shell in the wrong placebodyInShell</body>at the end countsuseIdgives the wrong IDs after a render that's thrown away, so a label points at the wrong inputuseIdThe boundaries are updated to the following from #509
Key changes in this pr:
<!--$s=-->…<!--/$s--><!--$s:ID-->fallback<!--/$s:ID--><!--$s?ID--><?start name="ID">fallback<?end><!--/$s?ID--><!--$s!:ID-->fallback<!--/$s:ID--><!--$s!-->fallback<!--/$s-->(no id)renderToStringAsync<!--$s-->…<!--/$s--><div hidden>wrapping<preact-island hidden data-target=ID>…</preact-island><template for="ID">…</template><script data-p="ID">$PRS()</script>, with no<div hidden>wrapper<svg>/<math>and the script getsdata-s$s:IDand renames it to$s!:ID<script data-p="ID" data-x>$PRS()</script>JS size changes
<preact-island>)<preact-island>…<!---->)<script data-p="id">$PRS()</script>Note
Written with Claude Fable 5.2 and Claude Opus 5.5, which also wrote this description. A review pass with Grok 4.7 added the handling of markers that already shipped.
I hope this PR helps. If it doesn't help, feel free to close it or modify it in any way that helps improve Preact.