GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Fizz/Flight] Don't start writing to the stream if it's already full by devknoll · Pull Request #22726 · react/react

Conversation

@devknoll

@devknoll devknoll commented Nov 9, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

Currently, React will always write something when flushing completed work, because it never checks if the stream is full until after writing. With this change, React will bail out early and continue buffering if we know we're still waiting for the stream to drain, so that we only write the most up-to-date data to the stream.

How did you test this change?

Existing tests pass. Could probably use a test to validate full behavior.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@facebook-github-bot facebook-github-bot added the CLA Signed label Nov 9, 2021
@sizebot

sizebot commented Nov 9, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: 2b77ab2...8b6d828

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 129.55 kB 129.55 kB = 41.43 kB 41.43 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 134.52 kB 134.52 kB = 42.89 kB 42.89 kB
facebook-www/ReactDOM-prod.classic.js = 423.36 kB 423.36 kB = 78.05 kB 78.05 kB
facebook-www/ReactDOM-prod.modern.js = 411.92 kB 411.92 kB = 76.30 kB 76.30 kB
facebook-www/ReactDOMForked-prod.classic.js = 423.36 kB 423.36 kB = 78.06 kB 78.06 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-flight-server.development.js +1.03% 1.95 kB 1.97 kB +0.85% 0.82 kB 0.83 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-flight-server.development.js +1.03% 1.95 kB 1.97 kB +0.85% 0.82 kB 0.83 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-flight-server.development.js +1.03% 1.95 kB 1.97 kB +0.85% 0.82 kB 0.83 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.node.production.min.server.js +1.02% 7.72 kB 7.80 kB +0.82% 3.06 kB 3.08 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.node.production.min.server.js +1.02% 7.72 kB 7.80 kB +0.82% 3.06 kB 3.08 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.node.production.min.server.js +1.02% 7.72 kB 7.80 kB +0.82% 3.06 kB 3.08 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.min.js +0.82% 0.97 kB 0.98 kB = 0.52 kB 0.52 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.min.js +0.82% 0.97 kB 0.98 kB = 0.52 kB 0.52 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.min.js +0.82% 0.97 kB 0.98 kB = 0.52 kB 0.52 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.node.development.server.js +0.69% 28.16 kB 28.35 kB +0.76% 7.54 kB 7.59 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.node.development.server.js +0.69% 28.16 kB 28.35 kB +0.76% 7.54 kB 7.59 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.node.development.server.js +0.69% 28.16 kB 28.35 kB +0.76% 7.54 kB 7.59 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-writer.browser.development.server.js +0.59% 29.68 kB 29.86 kB +0.27% 7.77 kB 7.79 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-writer.browser.development.server.js +0.59% 29.68 kB 29.86 kB +0.27% 7.77 kB 7.79 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-writer.browser.development.server.js +0.59% 29.68 kB 29.86 kB +0.27% 7.77 kB 7.79 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.production.min.server.js +0.58% 7.53 kB 7.58 kB +0.40% 3.02 kB 3.03 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.production.min.server.js +0.58% 7.53 kB 7.58 kB +0.40% 3.02 kB 3.03 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.production.min.server.js +0.58% 7.53 kB 7.58 kB +0.40% 3.02 kB 3.03 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.development.server.js +0.58% 27.98 kB 28.14 kB +0.26% 7.63 kB 7.65 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.development.server.js +0.58% 27.98 kB 28.14 kB +0.26% 7.63 kB 7.65 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.development.server.js +0.58% 27.98 kB 28.14 kB +0.26% 7.63 kB 7.65 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-writer.browser.production.min.server.js +0.57% 7.75 kB 7.80 kB +0.39% 3.12 kB 3.13 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-writer.browser.production.min.server.js +0.57% 7.75 kB 7.80 kB +0.39% 3.12 kB 3.13 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-writer.browser.production.min.server.js +0.57% 7.75 kB 7.80 kB +0.39% 3.12 kB 3.13 kB
oss-experimental/react-server/cjs/react-server-flight.production.min.js +0.36% 7.73 kB 7.76 kB +0.23% 3.09 kB 3.10 kB
oss-stable-semver/react-server/cjs/react-server-flight.production.min.js +0.36% 7.73 kB 7.76 kB +0.23% 3.09 kB 3.10 kB
oss-stable/react-server/cjs/react-server-flight.production.min.js +0.36% 7.73 kB 7.76 kB +0.23% 3.09 kB 3.10 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-server.development.js +0.34% 5.84 kB 5.86 kB = 1.63 kB 1.63 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-server.development.js +0.34% 5.84 kB 5.86 kB = 1.63 kB 1.63 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-server.development.js +0.34% 5.84 kB 5.86 kB = 1.63 kB 1.63 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-server.production.min.js +0.28% 2.85 kB 2.86 kB = 1.10 kB 1.10 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-server.production.min.js +0.28% 2.85 kB 2.86 kB = 1.10 kB 1.10 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-server.production.min.js +0.28% 2.85 kB 2.86 kB = 1.10 kB 1.10 kB
oss-stable-semver/react-server/cjs/react-server.production.min.js +0.28% 19.49 kB 19.54 kB +0.15% 6.81 kB 6.82 kB
oss-stable/react-server/cjs/react-server.production.min.js +0.28% 19.49 kB 19.54 kB +0.15% 6.81 kB 6.82 kB
oss-experimental/react-server/cjs/react-server.production.min.js +0.27% 19.67 kB 19.72 kB +0.15% 6.87 kB 6.88 kB
oss-stable-semver/react-dom/umd/react-dom-server.browser.production.min.js +0.27% 32.76 kB 32.85 kB +0.15% 11.27 kB 11.28 kB
oss-stable/react-dom/umd/react-dom-server.browser.production.min.js +0.27% 32.76 kB 32.85 kB +0.15% 11.27 kB 11.28 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.production.min.js +0.26% 32.60 kB 32.69 kB +0.16% 11.15 kB 11.17 kB
oss-stable/react-dom/cjs/react-dom-server.browser.production.min.js +0.26% 32.60 kB 32.69 kB +0.16% 11.15 kB 11.17 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.production.min.js +0.26% 32.74 kB 32.82 kB +0.17% 11.21 kB 11.22 kB
oss-experimental/react-dom/umd/react-dom-server.browser.production.min.js +0.26% 32.90 kB 32.99 kB +0.19% 11.31 kB 11.33 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.production.min.js +0.26% 35.71 kB 35.80 kB +0.32% 12.11 kB 12.15 kB
oss-stable/react-dom/cjs/react-dom-server.node.production.min.js +0.26% 35.71 kB 35.80 kB +0.32% 12.11 kB 12.15 kB
oss-experimental/react-dom/cjs/react-dom-server.node.production.min.js +0.26% 35.90 kB 35.99 kB +0.32% 12.18 kB 12.22 kB
oss-experimental/react-server/cjs/react-server-flight.development.js +0.20% 27.43 kB 27.49 kB +0.08% 7.33 kB 7.34 kB
oss-stable-semver/react-server/cjs/react-server-flight.development.js +0.20% 27.43 kB 27.49 kB +0.08% 7.33 kB 7.34 kB
oss-stable/react-server/cjs/react-server-flight.development.js +0.20% 27.43 kB 27.49 kB +0.08% 7.33 kB 7.34 kB

Generated by 🚫 dangerJS against 8b6d828

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@devknoll
Don't try writing if the stream is full
8b6d828
@devknoll devknoll changed the title Don't try writing if the stream is full [Fizz/Flight] Don't start writing to the stream if it's already full Nov 9, 2021
@devknoll
devknoll marked this pull request as ready for review November 9, 2021 17:50
@gaearon

gaearon commented Nov 9, 2021

Copy link
Copy Markdown
Collaborator

I don't have context on this and Seb is out for a bit. Is this blocking you?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@devknoll devknoll mentioned this pull request Dec 8, 2021
Document or fix known issues with this demo nextjs/next-react-server-components#13
Open
2 tasks
@gaearon

gaearon commented Dec 8, 2021

Copy link
Copy Markdown
Collaborator

ping @sebmarkbage

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sebmarkbage
sebmarkbage approved these changes Dec 9, 2021
View reviewed changes

@sebmarkbage sebmarkbage left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, this makes sense. The goal is that we'd ideally own the whole stream and at that point it'd be unnecessary to check this. At some point we might want to revert this for that reason. For now it's not practical to let React own the stream.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/react-server/src/ReactServerStreamConfigNode.js
destination.cork();
export function beginWriting(destination: Destination): boolean {
// Older versions of Node don't have this.
if (destination.writableNeedDrain !== true) {

@sebmarkbage sebmarkbage Dec 9, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about writableLength >= writableHighWaterMark? It goes back a little further in terms of Node versions. That's what write() practically returns, and what is checked before needDrain is set to true. It's also how we implement that for web streams.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

devknoll reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@jplhomer jplhomer mentioned this pull request Dec 9, 2021
Fix streaming SSR in react-dom/server.browser #22889
Closed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@sebmarkbage sebmarkbage sebmarkbage approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@devknoll @sizebot @gaearon @sebmarkbage @facebook-github-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.