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

Unify promise switch statements #25539

Merged
merged 3 commits into from
Oct 23, 2022
Merged

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Oct 23, 2022

Based on #25538

There are two different switch statements that we use to unwrap a use-ed promise, but there really only needs to be one. This was a factoring artifact that arose because I implemented the yieldy status instrumentation thing before I implemented use (for promises that are thrown directly during render, which is the old Suspense pattern that will be superseded by use).

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Oct 23, 2022
@sizebot
Copy link

sizebot commented Oct 23, 2022

Comparing: cce18e3...6612195

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 +0.08% 135.67 kB 135.78 kB +0.07% 43.46 kB 43.49 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 154.31 kB 154.20 kB +0.01% 49.20 kB 49.21 kB
facebook-www/ReactDOM-prod.classic.js = 493.82 kB 493.25 kB = 87.89 kB 87.84 kB
facebook-www/ReactDOM-prod.modern.js = 479.08 kB 478.51 kB = 85.71 kB 85.66 kB
facebook-www/ReactDOMForked-prod.classic.js = 493.82 kB 493.25 kB = 87.89 kB 87.84 kB
oss-stable-semver/react-server/cjs/react-server-flight.development.js = 54.85 kB 53.70 kB = 13.46 kB 13.07 kB
oss-stable/react-server/cjs/react-server-flight.development.js = 54.85 kB 53.70 kB = 13.46 kB 13.07 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js = 83.09 kB 81.34 kB = 20.68 kB 20.15 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js = 86.05 kB 84.23 kB = 20.88 kB 20.33 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js = 81.90 kB 80.15 kB = 20.63 kB 20.09 kB
facebook-relay/flight/ReactFlightNativeRelayServer-dev.js = 52.03 kB 50.87 kB = 12.99 kB 12.60 kB
facebook-www/ReactFlightDOMRelayServer-dev.modern.js = 72.12 kB 70.50 kB = 17.92 kB 17.39 kB
facebook-www/ReactFlightDOMRelayServer-dev.classic.js = 72.06 kB 70.44 kB = 17.90 kB 17.37 kB
oss-experimental/react-server/cjs/react-server-flight.development.js = 59.09 kB 57.34 kB = 14.51 kB 13.99 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/cjs/react-server-flight.production.min.js +0.74% 13.07 kB 13.16 kB +0.56% 4.81 kB 4.84 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +0.45% 21.78 kB 21.88 kB +0.42% 7.70 kB 7.73 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +0.44% 21.98 kB 22.08 kB +0.53% 7.78 kB 7.82 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +0.43% 22.16 kB 22.26 kB +0.45% 7.79 kB 7.82 kB
facebook-www/ReactFlightDOMRelayServer-prod.classic.js +0.30% 33.55 kB 33.65 kB +0.07% 8.48 kB 8.48 kB
facebook-www/ReactFlightDOMRelayServer-prod.modern.js +0.30% 33.63 kB 33.73 kB +0.08% 8.51 kB 8.51 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-prod.js +0.26% 281.41 kB 282.13 kB +0.29% 49.94 kB 50.08 kB
oss-stable-semver/react-test-renderer/cjs/react-test-renderer.development.js +0.24% 697.21 kB 698.91 kB +0.30% 150.82 kB 151.28 kB
oss-stable/react-test-renderer/cjs/react-test-renderer.development.js +0.24% 697.24 kB 698.94 kB +0.30% 150.85 kB 151.31 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-profiling.js +0.24% 297.00 kB 297.72 kB +0.28% 52.29 kB 52.44 kB
oss-stable-semver/react-test-renderer/umd/react-test-renderer.development.js +0.24% 730.35 kB 732.11 kB +0.30% 152.41 kB 152.86 kB
oss-stable/react-test-renderer/umd/react-test-renderer.development.js +0.24% 730.37 kB 732.13 kB +0.30% 152.43 kB 152.89 kB
oss-stable-semver/react-art/cjs/react-art.development.js +0.24% 719.08 kB 720.78 kB +0.28% 155.00 kB 155.44 kB
oss-stable/react-art/cjs/react-art.development.js +0.24% 719.10 kB 720.80 kB +0.29% 155.03 kB 155.47 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.development.js +0.23% 725.65 kB 727.35 kB +0.30% 156.54 kB 157.01 kB
react-native/implementations/ReactFabric-prod.js +0.23% 309.22 kB 309.94 kB +0.28% 54.75 kB 54.91 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-dev.js +0.23% 739.75 kB 741.47 kB +0.29% 158.09 kB 158.55 kB
oss-experimental/react-test-renderer/umd/react-test-renderer.development.js +0.23% 760.24 kB 762.00 kB +0.28% 158.21 kB 158.66 kB
react-native/implementations/ReactNativeRenderer-prod.js +0.23% 315.92 kB 316.64 kB +0.28% 55.82 kB 55.97 kB
facebook-www/ReactTestRenderer-dev.modern.js +0.23% 755.93 kB 757.65 kB +0.28% 161.29 kB 161.75 kB
facebook-www/ReactTestRenderer-dev.classic.js +0.23% 755.93 kB 757.65 kB +0.28% 161.29 kB 161.75 kB
react-native/implementations/ReactFabric-prod.fb.js +0.23% 319.60 kB 320.32 kB +0.26% 56.75 kB 56.90 kB
react-native/implementations/ReactNativeRenderer-prod.fb.js +0.22% 326.31 kB 327.03 kB +0.26% 57.83 kB 57.98 kB
react-native/implementations/ReactFabric-profiling.js +0.22% 328.31 kB 329.03 kB +0.27% 57.89 kB 58.05 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler.development.js +0.22% 787.90 kB 789.60 kB +0.27% 167.60 kB 168.05 kB
oss-stable/react-reconciler/cjs/react-reconciler.development.js +0.22% 787.92 kB 789.62 kB +0.27% 167.62 kB 168.07 kB
react-native/implementations/ReactNativeRenderer-profiling.js +0.21% 335.10 kB 335.82 kB +0.27% 58.92 kB 59.08 kB
oss-stable-semver/react-art/umd/react-art.development.js +0.21% 824.07 kB 825.83 kB +0.26% 173.13 kB 173.59 kB
oss-stable/react-art/umd/react-art.development.js +0.21% 824.09 kB 825.85 kB +0.26% 173.15 kB 173.61 kB
react-native/implementations/ReactFabric-dev.js +0.21% 818.27 kB 820.00 kB +0.25% 177.01 kB 177.46 kB
react-native/implementations/ReactNativeRenderer-dev.js +0.21% 827.82 kB 829.54 kB +0.25% 179.46 kB 179.90 kB
react-native/implementations/ReactFabric-profiling.fb.js +0.21% 346.38 kB 347.10 kB +0.27% 60.90 kB 61.06 kB
react-native/implementations/ReactNativeRenderer-profiling.fb.js +0.20% 353.15 kB 353.87 kB +0.28% 62.01 kB 62.18 kB
react-native/implementations/ReactFabric-dev.fb.js +0.20% 856.47 kB 858.19 kB +0.24% 184.33 kB 184.76 kB
facebook-relay/flight/ReactFlightNativeRelayServer-prod.js = 26.46 kB 26.40 kB = 6.38 kB 6.37 kB
oss-experimental/react-dom/cjs/react-dom-static.node.production.min.js = 54.95 kB 54.78 kB = 17.44 kB 17.42 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.production.min.js = 54.41 kB 54.24 kB = 16.73 kB 16.71 kB
oss-experimental/react-dom/cjs/react-dom-server.node.production.min.js = 54.95 kB 54.78 kB = 17.43 kB 17.42 kB
oss-experimental/react-dom/umd/react-dom-server.browser.production.min.js = 51.13 kB 50.96 kB = 16.57 kB 16.54 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.production.min.js = 51.06 kB 50.89 kB = 16.32 kB 16.30 kB
oss-experimental/react-dom/cjs/react-dom-static.browser.production.min.js = 50.94 kB 50.77 kB = 16.27 kB 16.26 kB
oss-experimental/react-dom/umd/react-dom-server-legacy.browser.production.min.js = 50.21 kB 50.05 kB = 15.74 kB 15.70 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.production.min.js = 50.11 kB 49.94 kB = 15.48 kB 15.47 kB
facebook-www/ReactDOMServer-dev.classic.js = 304.27 kB 302.44 kB = 69.21 kB 68.77 kB
facebook-www/ReactDOMServer-dev.modern.js = 297.58 kB 295.74 kB = 67.75 kB 67.29 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.development.js = 315.69 kB 313.71 kB = 72.41 kB 71.96 kB
facebook-www/ReactDOMServerStreaming-dev.modern.js = 293.08 kB 291.24 kB = 66.74 kB 66.27 kB
oss-experimental/react-dom/umd/react-dom-server-legacy.browser.development.js = 329.36 kB 327.29 kB = 72.68 kB 72.24 kB
oss-experimental/react-dom/cjs/react-dom-server.node.development.js = 314.38 kB 312.40 kB = 72.07 kB 71.62 kB
oss-experimental/react-dom/cjs/react-dom-static.node.development.js = 314.34 kB 312.36 kB = 72.17 kB 71.71 kB
oss-experimental/react-dom/umd/react-dom-server.browser.development.js = 328.58 kB 326.51 kB = 72.88 kB 72.44 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.development.js = 313.98 kB 312.01 kB = 71.94 kB 71.49 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.development.js = 313.21 kB 311.24 kB = 72.15 kB 71.69 kB
oss-experimental/react-dom/cjs/react-dom-static.browser.development.js = 312.52 kB 310.54 kB = 71.95 kB 71.50 kB
facebook-www/ReactDOMServerStreaming-prod.modern.js = 96.63 kB 96.00 kB = 19.85 kB 19.80 kB
facebook-www/ReactDOMServer-prod.classic.js = 95.71 kB 95.08 kB = 19.50 kB 19.45 kB
facebook-www/ReactDOMServer-prod.modern.js = 92.61 kB 91.98 kB = 18.85 kB 18.80 kB
oss-experimental/react-server/cjs/react-server.production.min.js = 23.95 kB 23.78 kB = 8.10 kB 8.08 kB
oss-experimental/react-server/cjs/react-server.development.js = 144.68 kB 142.71 kB = 36.03 kB 35.58 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js = 78.79 kB 77.64 kB = 19.58 kB 19.18 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js = 78.79 kB 77.64 kB = 19.58 kB 19.18 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js = 81.54 kB 80.35 kB = 19.78 kB 19.35 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js = 81.54 kB 80.35 kB = 19.78 kB 19.35 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js = 77.60 kB 76.45 kB = 19.52 kB 19.11 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js = 77.60 kB 76.45 kB = 19.52 kB 19.11 kB
oss-stable-semver/react-server/cjs/react-server-flight.development.js = 54.85 kB 53.70 kB = 13.46 kB 13.07 kB
oss-stable/react-server/cjs/react-server-flight.development.js = 54.85 kB 53.70 kB = 13.46 kB 13.07 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js = 83.09 kB 81.34 kB = 20.68 kB 20.15 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js = 86.05 kB 84.23 kB = 20.88 kB 20.33 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js = 81.90 kB 80.15 kB = 20.63 kB 20.09 kB
facebook-relay/flight/ReactFlightNativeRelayServer-dev.js = 52.03 kB 50.87 kB = 12.99 kB 12.60 kB
facebook-www/ReactFlightDOMRelayServer-dev.modern.js = 72.12 kB 70.50 kB = 17.92 kB 17.39 kB
facebook-www/ReactFlightDOMRelayServer-dev.classic.js = 72.06 kB 70.44 kB = 17.90 kB 17.37 kB
oss-experimental/react-server/cjs/react-server-flight.development.js = 59.09 kB 57.34 kB = 14.51 kB 13.99 kB

Generated by 🚫 dangerJS against 6612195

@acdlite acdlite marked this pull request as ready for review October 23, 2022 01:05
@acdlite acdlite force-pushed the unify-promise-switch branch 2 times, most recently from cf60b5f to 9e20bfd Compare October 23, 2022 03:23
Same as facebook#25537 but for Flight.

I was going to wait to do this later because the temporary
implementation of async components uses some of the same code that
non-used wakables do, but it's not so bad. I just had to inline one bit
of code, which we'll remove when we unify the implementation with `use`.
This is a refactor to track the array of thenables that is preserved
across replays in the work loop instead of the Thenable module.

The reason is that I'm about to add additional state to the Thenable
module that is specific to a particular attempt — like the current
index — and is reset between replays. So it's helpful to keep the two
kinds of state separate so it's clearer which state gets reset when.

The array of thenables is not reset until the work-in-progress either
completes or unwinds.

This also makes the structure more similar to Fizz and Flight.
There are two different switch statements that we use to unwrap a
`use`-ed promise, but there really only needs to be one. This was a
factoring artifact that arose because I implemented the yieldy `status`
instrumentation thing before I implemented `use` (for promises that are
thrown directly during render, which is the old Suspense pattern that
will be superseded by `use`).
@acdlite acdlite force-pushed the unify-promise-switch branch from 9e20bfd to 6612195 Compare October 23, 2022 05:10
@acdlite acdlite merged commit fa77f52 into facebook:main Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants