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

Suspend on uncaught error, if inside transition #23266

Closed
wants to merge 1 commit into from

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Feb 10, 2022

I started on this PR because I thought it would be helpful for implementing my next PR to allow suspending in the shell: #23267. However, the implementation details in that PR ended up going a different route, and now I'm unsure if we should keep the behavior in this PR. I'll leave this one open for discussion purposes, though.


Usually, if an error isn't caught by an error boundary, we treat it like a panic: the whole app will unmount and we'll throw a top-level error.

However, if we're in an async transition, what we can do instead is suspend the transition — i.e. remain on the current screen, like we do during a refresh when we're waiting for new data to load in the background.

The reason we only do this for transitions is because synchronous renders are expected to commit synchronously to maintain consistency with external state. (We arguably should suspend-on-uncaught-error for non-sync concurrent renders like continuous inputs, too, but that merits further discussion.)

When this happens, we will log the error with onRecoverableError. (This is a difference from the next PR, #23267, which implements similar behavior for suspending outside of a Suspense boundary. In that case, we don't log an error, because it's a supported pattern.)

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

sizebot commented Feb 10, 2022

Comparing: efd8f64...39b49c8

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.13% 130.34 kB 130.51 kB +0.09% 41.83 kB 41.87 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +0.13% 135.52 kB 135.69 kB +0.14% 43.34 kB 43.40 kB
facebook-www/ReactDOM-prod.classic.js +0.21% 431.14 kB 432.04 kB +0.16% 79.11 kB 79.24 kB
facebook-www/ReactDOM-prod.modern.js +0.21% 421.03 kB 421.93 kB +0.17% 77.66 kB 77.79 kB
facebook-www/ReactDOMForked-prod.classic.js +0.21% 431.14 kB 432.04 kB +0.16% 79.11 kB 79.24 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-semver/react-test-renderer/cjs/react-test-renderer.development.js +0.37% 614.61 kB 616.86 kB +0.41% 135.01 kB 135.57 kB
oss-stable/react-test-renderer/cjs/react-test-renderer.development.js +0.37% 614.61 kB 616.86 kB +0.41% 135.01 kB 135.57 kB
oss-stable-semver/react-test-renderer/umd/react-test-renderer.development.js +0.36% 644.34 kB 646.67 kB +0.40% 136.50 kB 137.05 kB
oss-stable/react-test-renderer/umd/react-test-renderer.development.js +0.36% 644.34 kB 646.67 kB +0.40% 136.50 kB 137.05 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-dev.js +0.35% 627.17 kB 629.39 kB +0.40% 136.19 kB 136.74 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.development.js +0.35% 641.29 kB 643.55 kB +0.40% 140.69 kB 141.25 kB
oss-experimental/react-test-renderer/umd/react-test-renderer.development.js +0.35% 672.34 kB 674.68 kB +0.39% 142.18 kB 142.73 kB
oss-stable-semver/react-art/cjs/react-art.development.js +0.34% 669.64 kB 671.89 kB +0.41% 144.77 kB 145.36 kB
oss-stable/react-art/cjs/react-art.development.js +0.34% 669.64 kB 671.89 kB +0.41% 144.77 kB 145.36 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer.production.min.js +0.33% 13.76 kB 13.81 kB +1.21% 3.97 kB 4.02 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer.production.min.js +0.33% 13.76 kB 13.81 kB +1.21% 3.97 kB 4.02 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer.production.min.js +0.33% 13.76 kB 13.81 kB +1.21% 3.97 kB 4.02 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-persistent.production.min.js +0.33% 13.83 kB 13.88 kB +1.18% 3.99 kB 4.04 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-persistent.production.min.js +0.33% 13.83 kB 13.88 kB +1.18% 3.99 kB 4.04 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-persistent.production.min.js +0.33% 13.83 kB 13.88 kB +1.18% 3.99 kB 4.04 kB
facebook-www/ReactTestRenderer-dev.classic.js +0.33% 675.32 kB 677.54 kB +0.40% 145.79 kB 146.38 kB
facebook-www/ReactTestRenderer-dev.modern.js +0.33% 675.33 kB 677.56 kB +0.40% 145.80 kB 146.38 kB
oss-experimental/react-art/cjs/react-art.development.js +0.32% 696.35 kB 698.60 kB +0.40% 150.42 kB 151.02 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler.development.js +0.31% 729.93 kB 732.22 kB +0.38% 155.38 kB 155.97 kB
oss-stable/react-reconciler/cjs/react-reconciler.development.js +0.31% 729.93 kB 732.22 kB +0.38% 155.38 kB 155.97 kB
react-native/implementations/ReactFabric-dev.js +0.31% 724.11 kB 726.34 kB +0.38% 157.82 kB 158.42 kB
oss-stable-semver/react-art/umd/react-art.development.js +0.30% 772.82 kB 775.16 kB +0.34% 163.06 kB 163.62 kB
oss-stable/react-art/umd/react-art.development.js +0.30% 772.82 kB 775.16 kB +0.34% 163.06 kB 163.62 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js +0.30% 756.83 kB 759.12 kB +0.35% 161.06 kB 161.63 kB
react-native/implementations/ReactNativeRenderer-dev.js +0.30% 736.53 kB 738.75 kB +0.37% 160.55 kB 161.14 kB
facebook-www/ReactART-dev.modern.js +0.30% 749.64 kB 751.86 kB +0.35% 160.09 kB 160.65 kB
facebook-www/ReactART-dev.classic.js +0.29% 759.86 kB 762.08 kB +0.35% 162.21 kB 162.78 kB
oss-experimental/react-art/umd/react-art.development.js +0.29% 800.83 kB 803.17 kB +0.32% 168.67 kB 169.21 kB
react-native/implementations/ReactFabric-dev.fb.js +0.29% 766.37 kB 768.59 kB +0.35% 165.55 kB 166.13 kB
react-native/implementations/ReactNativeRenderer-dev.fb.js +0.29% 776.93 kB 779.15 kB +0.34% 167.88 kB 168.46 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer.development.js +0.25% 42.08 kB 42.18 kB +0.33% 9.43 kB 9.46 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer.development.js +0.25% 42.08 kB 42.18 kB +0.33% 9.43 kB 9.46 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer.development.js +0.25% 42.08 kB 42.18 kB +0.33% 9.43 kB 9.46 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js +0.25% 42.21 kB 42.31 kB +0.33% 9.44 kB 9.47 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js +0.25% 42.21 kB 42.31 kB +0.33% 9.44 kB 9.47 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js +0.25% 42.21 kB 42.31 kB +0.33% 9.44 kB 9.47 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-prod.js +0.25% 237.88 kB 238.47 kB +0.25% 43.57 kB 43.67 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js +0.23% 991.20 kB 993.49 kB +0.26% 224.63 kB 225.21 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-profiling.js +0.23% 252.98 kB 253.57 kB +0.19% 45.96 kB 46.04 kB
oss-stable-semver/react-dom/cjs/react-dom.development.js +0.23% 1,002.12 kB 1,004.40 kB +0.24% 225.04 kB 225.58 kB
oss-stable/react-dom/cjs/react-dom.development.js +0.23% 1,002.12 kB 1,004.40 kB +0.24% 225.04 kB 225.58 kB
oss-stable-semver/react-dom/umd/react-dom.development.js +0.23% 1,051.84 kB 1,054.21 kB +0.25% 227.49 kB 228.06 kB
oss-stable/react-dom/umd/react-dom.development.js +0.23% 1,051.84 kB 1,054.21 kB +0.25% 227.49 kB 228.06 kB
facebook-www/ReactDOMTesting-dev.modern.js +0.22% 1,013.42 kB 1,015.68 kB +0.26% 228.43 kB 229.01 kB
oss-experimental/react-dom/cjs/react-dom.development.js +0.22% 1,031.46 kB 1,033.75 kB +0.25% 231.15 kB 231.72 kB
facebook-www/ReactDOMTesting-prod.modern.js +0.22% 409.30 kB 410.20 kB +0.16% 77.23 kB 77.36 kB
oss-experimental/react-dom/umd/react-dom.development.js +0.22% 1,082.61 kB 1,084.98 kB +0.23% 233.75 kB 234.30 kB
facebook-www/ReactDOMTesting-dev.classic.js +0.22% 1,040.38 kB 1,042.64 kB +0.25% 233.87 kB 234.45 kB
facebook-www/ReactDOM-prod.modern.js +0.21% 421.03 kB 421.93 kB +0.17% 77.66 kB 77.79 kB
facebook-www/ReactDOMForked-prod.modern.js +0.21% 421.03 kB 421.93 kB +0.17% 77.66 kB 77.79 kB
react-native/implementations/ReactFabric-prod.js +0.21% 274.10 kB 274.69 kB +0.18% 49.29 kB 49.38 kB
facebook-www/ReactDOMTesting-prod.classic.js +0.21% 422.78 kB 423.67 kB +0.15% 79.34 kB 79.46 kB
facebook-www/ReactDOM-prod.classic.js +0.21% 431.14 kB 432.04 kB +0.16% 79.11 kB 79.24 kB
facebook-www/ReactDOMForked-prod.classic.js +0.21% 431.14 kB 432.04 kB +0.16% 79.11 kB 79.24 kB
react-native/implementations/ReactNativeRenderer-prod.js +0.21% 282.71 kB 283.30 kB +0.19% 50.88 kB 50.97 kB
facebook-www/ReactDOM-profiling.modern.js +0.20% 451.60 kB 452.52 kB +0.20% 82.17 kB 82.33 kB
facebook-www/ReactDOMForked-profiling.modern.js +0.20% 451.60 kB 452.52 kB +0.20% 82.17 kB 82.33 kB
react-native/implementations/ReactFabric-prod.fb.js +0.20% 285.58 kB 286.17 kB +0.17% 51.49 kB 51.58 kB
facebook-www/ReactDOMForked-dev.modern.js +0.20% 1,106.66 kB 1,108.92 kB +0.23% 244.94 kB 245.50 kB
facebook-www/ReactDOM-dev.modern.js +0.20% 1,106.66 kB 1,108.92 kB +0.23% 244.94 kB 245.50 kB
react-native/implementations/ReactNativeRenderer-prod.fb.js +0.20% 289.52 kB 290.11 kB +0.17% 52.28 kB 52.37 kB
facebook-www/ReactDOM-profiling.classic.js +0.20% 461.77 kB 462.70 kB +0.17% 83.72 kB 83.86 kB
facebook-www/ReactDOMForked-profiling.classic.js +0.20% 461.77 kB 462.70 kB +0.17% 83.72 kB 83.86 kB

Generated by 🚫 dangerJS against 39b49c8

@acdlite acdlite marked this pull request as ready for review February 10, 2022 08:16
Usually, if an error isn't caught by an error boundary, we treat it
like a panic: the whole app will unmount and we'll throw a
top-level error.

However, if we're in an async transition, what we can do instead is
suspend the transition — i.e. remain on the current screen, like we do
during a refresh when we're waiting for new data to load in
the background.

The reason we only do this for transitions is because synchronous
renders are expected to commit synchronously to maintain consistency
with external state. (We arguably should suspend-on-uncaught-error for
non-sync concurrent renders like continuous inputs, too, but that merits
further discussion.)

The suspended error is logged with onRecoverableError.
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.

3 participants