Skip to content

[Not for merge] 16.6.2 release #14207

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

Closed
wants to merge 3 commits into from
Closed

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Nov 13, 2018

Suspense-related patches and proper support for context in the server renderer.

Includes everything up to b98adb6, then I cherry-picked
b545546 and 6c22b6c as well.

Opening this PR as a reference. Not for merge.

Test plan:

sebmarkbage and others added 3 commits November 12, 2018 17:50
…ook#14182)

* BUG: ReactPartialRenderer / New Context polutes mutable global state

The new context API stores the provided values on the shared context instance. When used in a synchronous context, this is not an issue. However when used in an concurrent context this can cause a "push provider" from one react render to have an effect on an unrelated concurrent react render.

I've encountered this bug in production when using renderToNodeStream, which asks ReactPartialRenderer for bytes up to a high water mark before yielding. If two Node Streams are created and read from in parallel, the state of one can polute the other.

I wrote a failing test to illustrate the conditions under which this happens.

I'm also concerned that the experimental concurrent/async React rendering on the client could suffer from the same issue.

* Use unique thread ID for each partial render to access Context

This first adds an allocator that keeps track of a unique ThreadID index
for each currently executing partial renderer. IDs are not just growing
but are reused as streams are destroyed.

This ensures that IDs are kept nice and compact.

This lets us use an "array" for each Context object to store the current
values. The look up for these are fast because they're just looking up
an offset in a tightly packed "array".

I don't use an actual Array object to store the values. Instead, I rely
on that VMs (notably V8) treat storage of numeric index property access
as a separate "elements" allocation.

This lets us avoid an extra indirection.

However, we must ensure that these arrays are not holey to preserve this
feature.

To do that I store the _threadCount on each context (effectively it takes
the place of the .length property on an array).

This lets us first validate that the context has enough slots before we
access the slot. If not, we fill in the slots with the default value.
@sizebot
Copy link

sizebot commented Nov 13, 2018

React: size: 🔺+0.1%, gzip: 🔺+0.1%

Details of bundled changes.

Comparing: d5e1bf0...0c756fb

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react.development.js +0.4% +0.4% 95.56 KB 95.93 KB 25.12 KB 25.21 KB UMD_DEV
react.production.min.js 🔺+0.1% 🔺+0.1% 11.52 KB 11.54 KB 4.58 KB 4.58 KB UMD_PROD
react.profiling.min.js +0.1% +0.2% 13.68 KB 13.69 KB 5.1 KB 5.11 KB UMD_PROFILING
react.development.js +0.6% +0.6% 59.52 KB 59.89 KB 16.12 KB 16.21 KB NODE_DEV
react.production.min.js 🔺+0.2% 🔺+0.2% 6.08 KB 6.09 KB 2.59 KB 2.6 KB NODE_PROD
React-dev.js +0.6% +0.6% 56.97 KB 57.34 KB 15.33 KB 15.43 KB FB_WWW_DEV
React-prod.js 🔺+0.1% 🔺+0.2% 14.99 KB 15.01 KB 4.03 KB 4.04 KB FB_WWW_PROD
React-profiling.js +0.1% +0.2% 14.99 KB 15.01 KB 4.03 KB 4.04 KB FB_WWW_PROFILING

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-server.browser.development.js +2.7% +3.1% 120.8 KB 124.11 KB 32.05 KB 33.03 KB UMD_DEV
react-dom-server.browser.production.min.js 🔺+3.8% 🔺+4.7% 16.34 KB 16.96 KB 6.21 KB 6.51 KB UMD_PROD
react-dom-server.browser.development.js +2.8% +3.2% 116.93 KB 120.24 KB 31.09 KB 32.09 KB NODE_DEV
react-dom-server.browser.production.min.js 🔺+3.8% 🔺+4.8% 16.24 KB 16.87 KB 6.2 KB 6.5 KB NODE_PROD
ReactDOMServer-dev.js +2.8% +3.2% 118.09 KB 121.42 KB 30.74 KB 31.73 KB FB_WWW_DEV
ReactDOMServer-prod.js 🔺+5.5% 🔺+4.5% 42.08 KB 44.41 KB 9.83 KB 10.28 KB FB_WWW_PROD
react-dom-server.node.development.js +2.9% +3.2% 118.86 KB 122.26 KB 31.62 KB 32.63 KB NODE_DEV
react-dom-server.node.production.min.js 🔺+4.0% 🔺+4.7% 17.05 KB 17.73 KB 6.5 KB 6.81 KB NODE_PROD

Generated by 🚫 dangerJS

@bvaughn
Copy link
Contributor

bvaughn commented Nov 13, 2018

16.6.3 is out so I'm going to close this PR~

@bvaughn bvaughn closed this Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants