Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[React 19] renderToPipeableStream emits </html> in different order? #32798

Open
liuyenwei opened this issue Apr 1, 2025 · 2 comments
Open

[React 19] renderToPipeableStream emits </html> in different order? #32798

liuyenwei opened this issue Apr 1, 2025 · 2 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@liuyenwei
Copy link
Contributor

liuyenwei commented Apr 1, 2025

React version: 19.1.0

We're currently upgrading from React 18 -> 19 and we're noticing what appears to be a slight change in the how renderToPipeableStream works. Specifically around the </body></html> being sent down as a separate chunk once all suspended content has been rendered.

Mostly curious if this an expected change? I went through the changelog but couldn't find anything that pointed to this.

Context
During server render, we discover "dynamic content" (image preload URLs, lazy load scripts, etc) and inject them into the response stream using a technique very similar to this. To ensure we don't start injecting too early, we will wait until the initial shell has been streamed down before we start injecting the dynamic content into the stream.

We noticed after upgrading to React 19, our previous assumptions were no longer valid since dynamic content was now being injected incorrectly between partial html.

Steps To Reproduce

  1. Render a full HTML document (containing something that suspends) using renderToPipeableStream.
    Ex:
<html lang="en">
  <head />
  <body>
    <Suspense fallback={<div>hello</div>}>
        <ThingThatSuspends />
     </Suspense>
  </body>
</html>
  1. Confirm that in React 18.3, </body></html> is sent as part of the initial chunk before ThingThatSuspends renders. Confirm in React 19, its sent down as a separate chunk after ThingThatSuspends renders.
@liuyenwei liuyenwei added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Apr 1, 2025
@eps1lon
Copy link
Collaborator

eps1lon commented Apr 2, 2025

Is this between 18.3 and 19.1 or 18.3 and 19.0? Curious if this only changed between 19.0 and 19.1

@liuyenwei
Copy link
Contributor Author

tested 19.0 and saw the same behavior so seems like between 18.3 and 19.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

2 participants