Repository navigation
Streamed document roots always lead with <!DOCTYPE html> (React Fizz parity) - #174
Merged
Merged
Conversation
…parity) React Fizz emits the doctype whenever the STREAMED root renders <html> — its test harness treats a doctype-less <html> as "almost certainly a bug in React" (per ReactDOMFizzServer-test.js:237, React canary b740af2) — while the buffered renderToString/renderToStaticMarkup emit none (verified against react-dom 19.2.7). Octane now matches on both sides: the streaming shell prepends <!DOCTYPE html> for document roots regardless of the injection option (previously document-mode-only), detected by an O(wrapper-depth) prefix scan so fragment streams pay a few byte compares; buffered renderers stay doctype-free (framework bot paths that want one — e.g. Start's prerender handler — already prepend it themselves). Also gates the injection branch's tail scan on the same document-root check, sparing injected fragment renders the full-body suffix scan. Evidence: doctype parity suite added to streaming-ssr-injection.test.ts (streamed pipeable/web documents lead with exactly one doctype, fragments never, buffered stays bare — the three streaming pins red-checked against the pre-change runtime); octane + octane-prod 7846 passed; full suite 11311 passed clean; website e2e 32/32 cold cache (the native Start path already emitted the doctype, so website output is byte-identical); streaming-ssr bench flat; typecheck/format/changeset green. Co-Authored-By: Claude Fable 5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was previously 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.
Why
The remaining octane follow-up from
docs/ssr-stream-injection-plan.md(after #169 and #168): the<!DOCTYPE html>preamble was gated on theinjectiondocument mode, but it is actually a React parity behavior — verified empirically against react-dom 19.2.7:renderToPipeableStream/renderToReadableStream): Fizz emits<!DOCTYPE html>whenever the root renders<html>; its own test harness asserts a doctype-less<html>is "almost certainly a bug in React" (ReactDOMFizzServer-test.js:237, canaryb740af2).renderToString/renderToStaticMarkup): no doctype — React leaves it to the caller.What
<!DOCTYPE html>for document roots unconditionally — detected by an O(wrapper-depth) prefix scan (hydration block markers +<html), so fragment streams pay a few byte compares, not a body scan. The injection document mode keeps its tail-holding/head-folding behavior but no longer owns the doctype.finalizeBufferedHtml) already prepends its own onto the buffered output — no doubling.docs/ssr.md), changeset, and the plan doc updated.Testing
streaming-ssr-injection.test.ts(× both compile modes): streamed pipeable + web documents lead with exactly one doctype, fragments never receive one, buffered document renders stay bare. The three streaming pins were red-checked against the pre-change runtime (exactly those fail, everything else passes).🤖 Generated with Claude Code
Note
Low Risk
Targeted streaming shell assembly change with explicit parity tests; buffered APIs and fragment streams are unchanged aside from documented doctype behavior.
Overview
Streaming SSR now prepends
<!DOCTYPE html>whenever the shell root is a document (<html>), matching React Fizz — not only wheninjectiondocument mode is active. Detection uses a cheap prefix scan (isDocumentRoot); fragments are unchanged.Injection document mode still holds the closing tail and folds styles/head into
<head>, but that path is gated ondocumentRootso injected fragment renders skip the full-body tail scan. BufferedrenderToString/renderToStaticMarkupstay doctype-free (React parity).Docs, changeset, and contract tests were updated; the no-injection streaming case now expects the doctype on the first chunk.
Reviewed by Cursor Bugbot for commit 308fdf7. Bugbot is set up for automated code reviews on this repo. Configure here.