Streaming hydration harness
Each test takes a tree with Suspense boundaries and streams it from the server, in several parts, into an iframe with document.write, so the real HTML parser sees it. The page is written in a random order mixed with hydration, lazy components finishing, re-renders, button clicks, reorders, hiding and showing, unmounts, parts split in two at a random byte, and connections that drop. When everything has arrived, the same tree is rendered from scratch next to it with the same actions, and the two are compared.
A run fails when the hydrated DOM differs from that fresh render (right away, after clicking every button, or after one more re-render), an effect ran twice or a ref was missing, an id shows up twice, or anything was logged as an error. Not counted as failures: glitch (an id was visible twice at some step) and kept (share of buttons still the nodes the parser created, so server DOM was hydrated rather than replaced).
Source code: MaxwellCohen/preact-streaming-harness.
Work compared: the client half, MaxwellCohen/preact#4 (also shown on its own, with render-to-string main), with step 1, MaxwellCohen/preact-render-to-string#12 (boundary ranges, <preact-island> chunks), and step 2, MaxwellCohen/preact-render-to-string#11 (the same ranges, <template for> chunks).
Totals
Loading...
Run it yourself
Side by side
The same JSX renders on the server and in the client. <Suspends server="a"> waits on the server until gate a opens, which sends one streamed chunk. <Suspends client="x"> waits on the client until gate x opens, like a lazy component that isn't loaded yet when hydration reaches it. seq lists the actions a schedule may fire. Each build column shows the comparison run (Chrome, same seed and schedules for every build) when it was recorded, otherwise the recorded stream run in Chrome. Run it yourself adds a second line, "your run".