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] Prevent uncloned large precomputed chunks without relying on render-time assertions by gnoff · Pull Request #28568 · react/react

Conversation

@gnoff

@gnoff gnoff commented Mar 15, 2024

Copy link
Copy Markdown
Collaborator

A while back we implemented a heuristic that if a chunk was large it was assumed to be produced by the render and thus was safe to stream which results in transferring the underlying object memory. Later we ran into an issue where a precomputed chunk grew large enough to trigger this hueristic and it started causing renders to fail because once a second render had occurred the precomputed chunk would not have an underlying buffer of bytes to send and these bytes would be omitted from the stream. We implemented a technique to detect large precomputed chunks and we enforced that these always be cloned before writing. Unfortunately our test coverage was not perfect and there has been for a very long time now a usage pattern where if you complete a boundary in one flush and then complete a boundary that has stylehsheet dependencies in another flush you can get a large precomputed chunk that was not being cloned to be sent twice causing streaming errors.

I've thought about why we even went with this solution in the first place and I think it was a mistake. It relies on a dev only check to catch paired with potentially version specific order of operations on the streaming side. This is too unreliable. Additionally the low limit of view size for Edge is not used in Node.js but there is not real justification for this.

In this change I updated the view size for edge streaming to match Node at 2048 bytes which is still relatively small and we have no data one way or another to preference 512 over this. Then I updated the assertion logic to error anytime a precomputed chunk exceeds the size. This eliminates the need to clone these chunks by just making sure our view size is always larger than the largest precomputed chunk we can possibly write. I'm generally in favor of this for a few reasons.

First, we'll always know during testing whether we've violated the limit as long as we exercise each stream config because the precomputed chunks are created in module scope. Second, we can always split up large chunks so making sure the precomptued chunk is smaller than whatever view size we actually desire is relatively trivial.

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 CLA Signed React Core Team Opened by a member of the React Core Team labels Mar 15, 2024
@gnoff
gnoff requested review from acdlite and sebmarkbage March 15, 2024 22:57
@react-sizebot

react-sizebot commented Mar 15, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Comparing: 966d174...76f7f70

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 = 177.19 kB 177.19 kB = 55.23 kB 55.23 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 177.72 kB 177.72 kB = 55.55 kB 55.55 kB
facebook-www/ReactDOM-prod.classic.js = 594.67 kB 594.67 kB = 105.04 kB 105.04 kB
facebook-www/ReactDOM-prod.modern.js = 577.93 kB 577.93 kB = 102.10 kB 102.10 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.js = 2.25 kB 2.20 kB = 0.88 kB 0.87 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.js = 2.25 kB 2.20 kB = 0.88 kB 0.87 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.js = 2.25 kB 2.20 kB = 0.88 kB 0.87 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-flight-server.development.js = 2.48 kB 2.41 kB = 0.94 kB 0.92 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-flight-server.development.js = 2.48 kB 2.41 kB = 0.94 kB 0.92 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-flight-server.development.js = 2.48 kB 2.41 kB = 0.94 kB 0.92 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.min.js = 1.35 kB 1.31 kB = 0.63 kB 0.62 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.min.js = 1.35 kB 1.31 kB = 0.63 kB 0.62 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.min.js = 1.35 kB 1.31 kB = 0.63 kB 0.62 kB
test_utils/ReactAllWarnings.js Deleted 66.60 kB 0.00 kB Deleted 16.28 kB 0.00 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-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js = 140.54 kB 140.06 kB = 31.23 kB 31.09 kB
oss-experimental/react-server-dom-turbopack/umd/react-server-dom-turbopack-server.browser.development.js = 137.97 kB 137.49 kB = 30.53 kB 30.39 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js = 134.36 kB 133.89 kB = 31.11 kB 30.98 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js = 133.31 kB 132.84 kB = 30.78 kB 30.64 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js = 139.26 kB 138.77 kB = 32.08 kB 31.93 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js = 132.43 kB 131.96 kB = 30.60 kB 30.46 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js = 130.86 kB 130.39 kB = 30.07 kB 29.93 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js = 136.98 kB 136.49 kB = 31.45 kB 31.29 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js = 136.63 kB 136.14 kB = 31.23 kB 31.08 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js = 134.34 kB 133.85 kB = 30.64 kB 30.48 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js = 128.18 kB 127.69 kB = 29.19 kB 29.03 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js = 118.15 kB 117.67 kB = 26.96 kB 26.82 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js = 118.15 kB 117.67 kB = 26.96 kB 26.82 kB
oss-stable-semver/react-server-dom-turbopack/umd/react-server-dom-turbopack-server.browser.development.js = 115.58 kB 115.10 kB = 26.28 kB 26.13 kB
oss-stable/react-server-dom-turbopack/umd/react-server-dom-turbopack-server.browser.development.js = 115.58 kB 115.10 kB = 26.28 kB 26.13 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js = 112.30 kB 111.84 kB = 26.71 kB 26.57 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js = 112.30 kB 111.84 kB = 26.71 kB 26.57 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js = 117.68 kB 117.19 kB = 27.81 kB 27.66 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js = 117.68 kB 117.19 kB = 27.81 kB 27.66 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js = 111.93 kB 111.46 kB = 26.64 kB 26.50 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js = 111.93 kB 111.46 kB = 26.64 kB 26.50 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js = 110.37 kB 109.91 kB = 26.21 kB 26.06 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js = 110.37 kB 109.91 kB = 26.21 kB 26.06 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js = 115.40 kB 114.90 kB = 27.20 kB 27.05 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js = 115.40 kB 114.90 kB = 27.20 kB 27.05 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js = 109.48 kB 109.01 kB = 25.97 kB 25.82 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js = 109.48 kB 109.01 kB = 25.97 kB 25.82 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js = 115.05 kB 114.55 kB = 26.93 kB 26.78 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js = 115.05 kB 114.55 kB = 26.93 kB 26.78 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js = 112.76 kB 112.26 kB = 26.37 kB 26.21 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js = 112.76 kB 112.26 kB = 26.37 kB 26.21 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js = 106.60 kB 106.11 kB = 24.99 kB 24.83 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js = 106.60 kB 106.11 kB = 24.99 kB 24.83 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.js = 2.25 kB 2.20 kB = 0.88 kB 0.87 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.js = 2.25 kB 2.20 kB = 0.88 kB 0.87 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.js = 2.25 kB 2.20 kB = 0.88 kB 0.87 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-flight-server.development.js = 2.48 kB 2.41 kB = 0.94 kB 0.92 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-flight-server.development.js = 2.48 kB 2.41 kB = 0.94 kB 0.92 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-flight-server.development.js = 2.48 kB 2.41 kB = 0.94 kB 0.92 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.min.js = 1.35 kB 1.31 kB = 0.63 kB 0.62 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.min.js = 1.35 kB 1.31 kB = 0.63 kB 0.62 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-flight-server.production.min.js = 1.35 kB 1.31 kB = 0.63 kB 0.62 kB
test_utils/ReactAllWarnings.js Deleted 66.60 kB 0.00 kB Deleted 16.28 kB 0.00 kB

Generated by 🚫 dangerJS against 76f7f70

All reactions

Sorry, something went wrong.

Uh oh!

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

@gnoff
gnoff force-pushed the fix-large-chunk branch from 0b6ede8 to ccf0165 Compare March 15, 2024 23:04
@gnoff
A while back we implemented a hueristic that if a chunk was large it …
76f7f70
…was assumed to be produced by the render and thus was safe to stream which results in transferring the underlying object memory. Later we ran into an issue where a precomputed chunk grew large enough to trigger this hueristic and it started causing renders to fail because once a second render had occured the precomputed chunk would not have an underlying buffer of bytes to send and these bytes would be omitted from the stream. We implemented a technique to detect large preocmputed chunks and we enforced that these always be cloned before writing. Unfortunately our test coverage was not perfect and there has been for a very long time now a usage pattern where if you complete a boundary in one flush and then complete a boundary that has stylehsheet dependencies in another flush you can get a large precomputed chunk that was not being cloned to be sent twice causing streaming errors.

I've thought about why we even went with this solution in the first place and I think it was a mistake. It relies on a dev only check to catch paired with potentially version speicifc order of operations on the streaming side. This is too unreliable. Additionally the low limit of view size for Edge is not used in Node.js but there is not real justification for this.

In this change I updated the view size for edge streaming to match Node at 2048 bytes which is still relatively small and we have no data one way or another to preference 512 over this. Then I updated the assertion logic to error anytime a precomputed chunk exceeds the size. This eliminates the need to clone these chunks by just making sure our view size is awlays larger than the largest precomputed chunk we can possibly write. I'm generally in favor of this for a few reasons.

First, we'll always know during testing whether we've violated the limit as long as we exercise each stream config because the precomputed chunks are created in module scope.
Second, we can always split up large chunks so making sure the precomptued chunk is smaller than whatever view size we actually desire is relatively trivial.
@gnoff
gnoff force-pushed the fix-large-chunk branch from ccf0165 to 76f7f70 Compare March 15, 2024 23:07
sebmarkbage
sebmarkbage reviewed Mar 16, 2024
View reviewed changes

@sebmarkbage sebmarkbage left a comment •
edited
Loading

Uh oh!

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

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.

Well we do know that we flush much more often than a typical streaming service would so whatever the default is for others doesn’t necessarily make sense for us anyway.

The risk is that with many small flushes we eat up a ton of unnecessary memory.

Sorry, something went wrong.

Uh oh!

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

All reactions
sebmarkbage
sebmarkbage approved these changes Mar 16, 2024
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.

For the really large chunks we could just split up the scripts. (Although they’re getting a bit too large already.)

Sorry, something went wrong.

Uh oh!

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

All reactions
@gnoff

gnoff commented Mar 16, 2024

Copy link
Copy Markdown
Collaborator Author

Yeah I suppose edge has implied tighter memory constraints. Do you think the transferred buffers are likely to not be freed quickly?

but yes I came to the same conclusion that it’s trivial for us to split up our large chunks to make them smaller and that is less bad than accidentally failing to assert the copy like what happened in the case I’m fixing

All reactions

Sorry, something went wrong.

Uh oh!

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

@gnoff
gnoff merged commit b09e102 into react:main Mar 16, 2024
@gnoff
gnoff deleted the fix-large-chunk branch March 16, 2024 19:39
github-actions Bot pushed a commit that referenced this pull request Mar 16, 2024
@gnoff
[Fizz] Prevent uncloned large precomputed chunks without relying on r…
d06d633
…ender-time assertions (#28568)

A while back we implemented a heuristic that if a chunk was large it was
assumed to be produced by the render and thus was safe to stream which
results in transferring the underlying object memory. Later we ran into
an issue where a precomputed chunk grew large enough to trigger this
hueristic and it started causing renders to fail because once a second
render had occurred the precomputed chunk would not have an underlying
buffer of bytes to send and these bytes would be omitted from the
stream. We implemented a technique to detect large precomputed chunks
and we enforced that these always be cloned before writing.
Unfortunately our test coverage was not perfect and there has been for a
very long time now a usage pattern where if you complete a boundary in
one flush and then complete a boundary that has stylehsheet dependencies
in another flush you can get a large precomputed chunk that was not
being cloned to be sent twice causing streaming errors.

I've thought about why we even went with this solution in the first
place and I think it was a mistake. It relies on a dev only check to
catch paired with potentially version specific order of operations on
the streaming side. This is too unreliable. Additionally the low limit
of view size for Edge is not used in Node.js but there is not real
justification for this.

In this change I updated the view size for edge streaming to match Node
at 2048 bytes which is still relatively small and we have no data one
way or another to preference 512 over this. Then I updated the assertion
logic to error anytime a precomputed chunk exceeds the size. This
eliminates the need to clone these chunks by just making sure our view
size is always larger than the largest precomputed chunk we can possibly
write. I'm generally in favor of this for a few reasons.

First, we'll always know during testing whether we've violated the limit
as long as we exercise each stream config because the precomputed chunks
are created in module scope. Second, we can always split up large chunks
so making sure the precomptued chunk is smaller than whatever view size
we actually desire is relatively trivial.

DiffTrain build for [b09e102](b09e102)
gnoff added a commit to gnoff/react that referenced this pull request Mar 18, 2024
@gnoff
[Fizz] Prevent uncloned large precomputed chunks without relying on r…
72e7c90
…ender-time assertions (react#28568)

A while back we implemented a heuristic that if a chunk was large it was
assumed to be produced by the render and thus was safe to stream which
results in transferring the underlying object memory. Later we ran into
an issue where a precomputed chunk grew large enough to trigger this
hueristic and it started causing renders to fail because once a second
render had occurred the precomputed chunk would not have an underlying
buffer of bytes to send and these bytes would be omitted from the
stream. We implemented a technique to detect large precomputed chunks
and we enforced that these always be cloned before writing.
Unfortunately our test coverage was not perfect and there has been for a
very long time now a usage pattern where if you complete a boundary in
one flush and then complete a boundary that has stylehsheet dependencies
in another flush you can get a large precomputed chunk that was not
being cloned to be sent twice causing streaming errors.

I've thought about why we even went with this solution in the first
place and I think it was a mistake. It relies on a dev only check to
catch paired with potentially version specific order of operations on
the streaming side. This is too unreliable. Additionally the low limit
of view size for Edge is not used in Node.js but there is not real
justification for this.

In this change I updated the view size for edge streaming to match Node
at 2048 bytes which is still relatively small and we have no data one
way or another to preference 512 over this. Then I updated the assertion
logic to error anytime a precomputed chunk exceeds the size. This
eliminates the need to clone these chunks by just making sure our view
size is always larger than the largest precomputed chunk we can possibly
write. I'm generally in favor of this for a few reasons.

First, we'll always know during testing whether we've violated the limit
as long as we exercise each stream config because the precomputed chunks
are created in module scope. Second, we can always split up large chunks
so making sure the precomptued chunk is smaller than whatever view size
we actually desire is relatively trivial.
@gnoff gnoff mentioned this pull request Mar 18, 2024
(cherrypick b09e102f) [Fizz] Prevent uncloned large precomputed chunks without relying on render-time assertions #28580
Merged
gnoff added a commit that referenced this pull request Mar 18, 2024
@gnoff
(cherrypick b09e102) [Fizz] Prevent uncloned large precomputed chunks…
14898b6
… without relying on render-time assertions (#28580)

(cherrypick b09e102 #28568)

[Fizz] Prevent uncloned large precomputed chunks without relying on
render-time assertions (#28568)

A while back we implemented a heuristic that if a chunk was large it was
assumed to be produced by the render and thus was safe to stream which
results in transferring the underlying object memory. Later we ran into
an issue where a precomputed chunk grew large enough to trigger this
hueristic and it started causing renders to fail because once a second
render had occurred the precomputed chunk would not have an underlying
buffer of bytes to send and these bytes would be omitted from the
stream. We implemented a technique to detect large precomputed chunks
and we enforced that these always be cloned before writing.
Unfortunately our test coverage was not perfect and there has been for a
very long time now a usage pattern where if you complete a boundary in
one flush and then complete a boundary that has stylehsheet dependencies
in another flush you can get a large precomputed chunk that was not
being cloned to be sent twice causing streaming errors.

I've thought about why we even went with this solution in the first
place and I think it was a mistake. It relies on a dev only check to
catch paired with potentially version specific order of operations on
the streaming side. This is too unreliable. Additionally the low limit
of view size for Edge is not used in Node.js but there is not real
justification for this.

In this change I updated the view size for edge streaming to match Node
at 2048 bytes which is still relatively small and we have no data one
way or another to preference 512 over this. Then I updated the assertion
logic to error anytime a precomputed chunk exceeds the size. This
eliminates the need to clone these chunks by just making sure our view
size is always larger than the largest precomputed chunk we can possibly
write. I'm generally in favor of this for a few reasons.

First, we'll always know during testing whether we've violated the limit
as long as we exercise each stream config because the precomputed chunks
are created in module scope. Second, we can always split up large chunks
so making sure the precomptued chunk is smaller than whatever view size
we actually desire is relatively trivial.
gnoff added a commit to gnoff/react that referenced this pull request Mar 19, 2024
@gnoff
[Fizz] Prevent uncloned large precomputed chunks without relying on r…
0a8846d
…ender-time assertions (react#28568)

A while back we implemented a heuristic that if a chunk was large it was
assumed to be produced by the render and thus was safe to stream which
results in transferring the underlying object memory. Later we ran into
an issue where a precomputed chunk grew large enough to trigger this
hueristic and it started causing renders to fail because once a second
render had occurred the precomputed chunk would not have an underlying
buffer of bytes to send and these bytes would be omitted from the
stream. We implemented a technique to detect large precomputed chunks
and we enforced that these always be cloned before writing.
Unfortunately our test coverage was not perfect and there has been for a
very long time now a usage pattern where if you complete a boundary in
one flush and then complete a boundary that has stylehsheet dependencies
in another flush you can get a large precomputed chunk that was not
being cloned to be sent twice causing streaming errors.

I've thought about why we even went with this solution in the first
place and I think it was a mistake. It relies on a dev only check to
catch paired with potentially version specific order of operations on
the streaming side. This is too unreliable. Additionally the low limit
of view size for Edge is not used in Node.js but there is not real
justification for this.

In this change I updated the view size for edge streaming to match Node
at 2048 bytes which is still relatively small and we have no data one
way or another to preference 512 over this. Then I updated the assertion
logic to error anytime a precomputed chunk exceeds the size. This
eliminates the need to clone these chunks by just making sure our view
size is always larger than the largest precomputed chunk we can possibly
write. I'm generally in favor of this for a few reasons.

First, we'll always know during testing whether we've violated the limit
as long as we exercise each stream config because the precomputed chunks
are created in module scope. Second, we can always split up large chunks
so making sure the precomptued chunk is smaller than whatever view size
we actually desire is relatively trivial.
@gnoff gnoff mentioned this pull request Mar 19, 2024
(cherrypick b09e102f) [Fizz] Prevent uncloned large precomputed chunks without relying on render-time assertions #28580 #28585
Merged
gnoff added a commit that referenced this pull request Mar 19, 2024
@gnoff
(cherrypick b09e102) [Fizz] Prevent uncloned large precomputed chunk…
4b84f11
…s without relying on render-time assertions #28580  (#28585)

(cherrypick b09e102 on 60a927d)

[Fizz] Prevent uncloned large precomputed chunks without relying on
render-time assertions (#28568)

A while back we implemented a heuristic that if a chunk was large it was
assumed to be produced by the render and thus was safe to stream which
results in transferring the underlying object memory. Later we ran into
an issue where a precomputed chunk grew large enough to trigger this
hueristic and it started causing renders to fail because once a second
render had occurred the precomputed chunk would not have an underlying
buffer of bytes to send and these bytes would be omitted from the
stream. We implemented a technique to detect large precomputed chunks
and we enforced that these always be cloned before writing.
Unfortunately our test coverage was not perfect and there has been for a
very long time now a usage pattern where if you complete a boundary in
one flush and then complete a boundary that has stylehsheet dependencies
in another flush you can get a large precomputed chunk that was not
being cloned to be sent twice causing streaming errors.

I've thought about why we even went with this solution in the first
place and I think it was a mistake. It relies on a dev only check to
catch paired with potentially version specific order of operations on
the streaming side. This is too unreliable. Additionally the low limit
of view size for Edge is not used in Node.js but there is not real
justification for this.

In this change I updated the view size for edge streaming to match Node
at 2048 bytes which is still relatively small and we have no data one
way or another to preference 512 over this. Then I updated the assertion
logic to error anytime a precomputed chunk exceeds the size. This
eliminates the need to clone these chunks by just making sure our view
size is always larger than the largest precomputed chunk we can possibly
write. I'm generally in favor of this for a few reasons.

First, we'll always know during testing whether we've violated the limit
as long as we exercise each stream config because the precomputed chunks
are created in module scope. Second, we can always split up large chunks
so making sure the precomptued chunk is smaller than whatever view size
we actually desire is relatively trivial.
@ztanner ztanner mentioned this pull request Mar 21, 2024
Update React from 6c3b8dbfe to a4939017f vercel/next.js#63413
Closed
@gnoff gnoff mentioned this pull request Mar 25, 2024
Update React from 14898b6a9 to e373190fa vercel/next.js#63685
Closed
gnoff added a commit to gnoff/next.js that referenced this pull request Mar 25, 2024
@gnoff
Update React from 14898b6a9 to e373190fa
1a2ce1f
- react/react#28596
- react/react#28625
- react/react#28616
- react/react#28491
- react/react#28583
- react/react#28427
- react/react#28613
- react/react#28599
- react/react#28611
- react/react#28610
- react/react#28606
- react/react#28598
- react/react#28549
- react/react#28557
- react/react#28467
- react/react#28591
- react/react#28459
- react/react#28590
- react/react#28564
- react/react#28582
- react/react#28579
- react/react#28578
- react/react#28521
- react/react#28550
- react/react#28576
- react/react#28577
- react/react#28571
- react/react#28572
- react/react#28560
- react/react#28569
- react/react#28573
- react/react#28546
- react/react#28568
- react/react#28562
- react/react#28566
- react/react#28565
- react/react#28559
- react/react#28508
- react/react#20432
- react/react#28555
- react/react#24730
- react/react#28472
- react/react#27991
- react/react#28514
- react/react#28548
- react/react#28526
- react/react#28515
- react/react#28533
- react/react#28532
- react/react#28531
- react/react#28407
- react/react#28522
- react/react#28538
- react/react#28509
- react/react#28534
- react/react#28527
- react/react#28528
- react/react#28519
- react/react#28411
- react/react#28520
- react/react#28518
- react/react#28493
- react/react#28504
- react/react#28499
- react/react#28501
- react/react#28496
- react/react#28471
- react/react#28351
- react/react#28486
- react/react#28490
- react/react#28488
- react/react#28468
- react/react#28321
- react/react#28477
- react/react#28479
- react/react#28480
- react/react#28478
- react/react#28464
- react/react#28475
- react/react#28456
- react/react#28319
- react/react#28345
- react/react#28337
- react/react#28335
- react/react#28466
- react/react#28462
- react/react#28322
- react/react#28444
- react/react#28448
- react/react#28449
- react/react#28446
- react/react#28447
- react/react#24580
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
@gnoff @AndyPengc12
[Fizz] Prevent uncloned large precomputed chunks without relying on r…
002e585
…ender-time assertions (react#28568)

A while back we implemented a heuristic that if a chunk was large it was
assumed to be produced by the render and thus was safe to stream which
results in transferring the underlying object memory. Later we ran into
an issue where a precomputed chunk grew large enough to trigger this
hueristic and it started causing renders to fail because once a second
render had occurred the precomputed chunk would not have an underlying
buffer of bytes to send and these bytes would be omitted from the
stream. We implemented a technique to detect large precomputed chunks
and we enforced that these always be cloned before writing.
Unfortunately our test coverage was not perfect and there has been for a
very long time now a usage pattern where if you complete a boundary in
one flush and then complete a boundary that has stylehsheet dependencies
in another flush you can get a large precomputed chunk that was not
being cloned to be sent twice causing streaming errors.

I've thought about why we even went with this solution in the first
place and I think it was a mistake. It relies on a dev only check to
catch paired with potentially version specific order of operations on
the streaming side. This is too unreliable. Additionally the low limit
of view size for Edge is not used in Node.js but there is not real
justification for this.

In this change I updated the view size for edge streaming to match Node
at 2048 bytes which is still relatively small and we have no data one
way or another to preference 512 over this. Then I updated the assertion
logic to error anytime a precomputed chunk exceeds the size. This
eliminates the need to clone these chunks by just making sure our view
size is always larger than the largest precomputed chunk we can possibly
write. I'm generally in favor of this for a few reasons.

First, we'll always know during testing whether we've violated the limit
as long as we exercise each stream config because the precomputed chunks
are created in module scope. Second, we can always split up large chunks
so making sure the precomptued chunk is smaller than whatever view size
we actually desire is relatively trivial.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
@gnoff
[Fizz] Prevent uncloned large precomputed chunks without relying on r…
77beaa1
…ender-time assertions (#28568)

A while back we implemented a heuristic that if a chunk was large it was
assumed to be produced by the render and thus was safe to stream which
results in transferring the underlying object memory. Later we ran into
an issue where a precomputed chunk grew large enough to trigger this
hueristic and it started causing renders to fail because once a second
render had occurred the precomputed chunk would not have an underlying
buffer of bytes to send and these bytes would be omitted from the
stream. We implemented a technique to detect large precomputed chunks
and we enforced that these always be cloned before writing.
Unfortunately our test coverage was not perfect and there has been for a
very long time now a usage pattern where if you complete a boundary in
one flush and then complete a boundary that has stylehsheet dependencies
in another flush you can get a large precomputed chunk that was not
being cloned to be sent twice causing streaming errors.

I've thought about why we even went with this solution in the first
place and I think it was a mistake. It relies on a dev only check to
catch paired with potentially version specific order of operations on
the streaming side. This is too unreliable. Additionally the low limit
of view size for Edge is not used in Node.js but there is not real
justification for this.

In this change I updated the view size for edge streaming to match Node
at 2048 bytes which is still relatively small and we have no data one
way or another to preference 512 over this. Then I updated the assertion
logic to error anytime a precomputed chunk exceeds the size. This
eliminates the need to clone these chunks by just making sure our view
size is always larger than the largest precomputed chunk we can possibly
write. I'm generally in favor of this for a few reasons.

First, we'll always know during testing whether we've violated the limit
as long as we exercise each stream config because the precomputed chunks
are created in module scope. Second, we can always split up large chunks
so making sure the precomptued chunk is smaller than whatever view size
we actually desire is relatively trivial.

DiffTrain build for commit b09e102.
@eps1lon eps1lon mentioned this pull request Apr 19, 2024
Update React from 14898b6a9 to c3048aab4 vercel/next.js#64798
Merged
gnoff added a commit to gnoff/react that referenced this pull request Dec 18, 2024
@gnoff
(cherrypick b09e102) [Fizz] Prevent uncloned large precomputed chunks…
3ea95e4
… without relying on render-time assertions (react#28580)

(cherrypick b09e102 react#28568)

[Fizz] Prevent uncloned large precomputed chunks without relying on
render-time assertions (react#28568)

A while back we implemented a heuristic that if a chunk was large it was
assumed to be produced by the render and thus was safe to stream which
results in transferring the underlying object memory. Later we ran into
an issue where a precomputed chunk grew large enough to trigger this
hueristic and it started causing renders to fail because once a second
render had occurred the precomputed chunk would not have an underlying
buffer of bytes to send and these bytes would be omitted from the
stream. We implemented a technique to detect large precomputed chunks
and we enforced that these always be cloned before writing.
Unfortunately our test coverage was not perfect and there has been for a
very long time now a usage pattern where if you complete a boundary in
one flush and then complete a boundary that has stylehsheet dependencies
in another flush you can get a large precomputed chunk that was not
being cloned to be sent twice causing streaming errors.

I've thought about why we even went with this solution in the first
place and I think it was a mistake. It relies on a dev only check to
catch paired with potentially version specific order of operations on
the streaming side. This is too unreliable. Additionally the low limit
of view size for Edge is not used in Node.js but there is not real
justification for this.

In this change I updated the view size for edge streaming to match Node
at 2048 bytes which is still relatively small and we have no data one
way or another to preference 512 over this. Then I updated the assertion
logic to error anytime a precomputed chunk exceeds the size. This
eliminates the need to clone these chunks by just making sure our view
size is always larger than the largest precomputed chunk we can possibly
write. I'm generally in favor of this for a few reasons.

First, we'll always know during testing whether we've violated the limit
as long as we exercise each stream config because the precomputed chunks
are created in module scope. Second, we can always split up large chunks
so making sure the precomptued chunk is smaller than whatever view size
we actually desire is relatively trivial.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@gnoff
[Fizz] Prevent uncloned large precomputed chunks without relying on r…
68c3301
…ender-time assertions (react#28568)

A while back we implemented a heuristic that if a chunk was large it was
assumed to be produced by the render and thus was safe to stream which
results in transferring the underlying object memory. Later we ran into
an issue where a precomputed chunk grew large enough to trigger this
hueristic and it started causing renders to fail because once a second
render had occurred the precomputed chunk would not have an underlying
buffer of bytes to send and these bytes would be omitted from the
stream. We implemented a technique to detect large precomputed chunks
and we enforced that these always be cloned before writing.
Unfortunately our test coverage was not perfect and there has been for a
very long time now a usage pattern where if you complete a boundary in
one flush and then complete a boundary that has stylehsheet dependencies
in another flush you can get a large precomputed chunk that was not
being cloned to be sent twice causing streaming errors.

I've thought about why we even went with this solution in the first
place and I think it was a mistake. It relies on a dev only check to
catch paired with potentially version specific order of operations on
the streaming side. This is too unreliable. Additionally the low limit
of view size for Edge is not used in Node.js but there is not real
justification for this.

In this change I updated the view size for edge streaming to match Node
at 2048 bytes which is still relatively small and we have no data one
way or another to preference 512 over this. Then I updated the assertion
logic to error anytime a precomputed chunk exceeds the size. This
eliminates the need to clone these chunks by just making sure our view
size is always larger than the largest precomputed chunk we can possibly
write. I'm generally in favor of this for a few reasons.

First, we'll always know during testing whether we've violated the limit
as long as we exercise each stream config because the precomputed chunks
are created in module scope. Second, we can always split up large chunks
so making sure the precomptued chunk is smaller than whatever view size
we actually desire is relatively trivial.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@acdlite acdlite Awaiting requested review from acdlite
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 React Core Team Opened by a member of the React Core Team

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.

4 participants

@gnoff @react-sizebot @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.