Skip to content

[Fresh] Retry failed roots on refresh#15966

Merged
gaearon merged 2 commits intofacebook:masterfrom
gaearon:retry-roots
Jun 24, 2019
Merged

[Fresh] Retry failed roots on refresh#15966
gaearon merged 2 commits intofacebook:masterfrom
gaearon:retry-roots

Conversation

@gaearon
Copy link
Copy Markdown
Collaborator

@gaearon gaearon commented Jun 23, 2019

This aligns the behavior for roots with error boundaries. When a root unmounts as a result of an error, if the Fresh runtime is running, it will record its last rendered element in a Map.

There is a new scheduleRoot(root, element) DevTools hook. Fresh runtime calls it on update for all failed roots with their last rendered elements. This offers us an opportunity to remount the tree.

We remove a root from the failed map if there is a further update on it that isn't caused by an error. In order to determine whether an update is caused by an error, we check effectTag. This is done before calling onCommitFiberRoot so that Fresh runtime itself doesn't depend on a particular tag constant.

@sizebot
Copy link
Copy Markdown

sizebot commented Jun 23, 2019

ReactDOM: size: 0.0%, gzip: 0.0%

Details of bundled changes.

Comparing: 39b97e8...651cb27

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js 0.0% 0.0% 114.12 KB 114.17 KB 36.02 KB 36.04 KB NODE_PROFILING
ReactDOM-dev.js +0.1% +0.1% 920.76 KB 921.33 KB 204.2 KB 204.35 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10.74 KB 10.74 KB 3.68 KB 3.68 KB UMD_PROD
react-dom-unstable-fire.development.js +0.1% +0.1% 897.54 KB 898.1 KB 203.88 KB 204.04 KB UMD_DEV
react-dom-unstable-fire.production.min.js 0.0% 🔺+0.1% 110.52 KB 110.58 KB 35.56 KB 35.58 KB UMD_PROD
react-dom-unstable-fire.profiling.min.js 0.0% +0.1% 113.85 KB 113.9 KB 36.6 KB 36.63 KB UMD_PROFILING
react-dom-unstable-fire.development.js +0.1% +0.1% 891.84 KB 892.4 KB 202.38 KB 202.53 KB NODE_DEV
react-dom-unstable-fire.production.min.js 0.0% 0.0% 110.6 KB 110.65 KB 35.14 KB 35.16 KB NODE_PROD
react-dom.development.js +0.1% +0.1% 897.2 KB 897.76 KB 203.74 KB 203.89 KB UMD_DEV
react-dom-unstable-fire.profiling.min.js 0.0% 0.0% 114.13 KB 114.18 KB 36.03 KB 36.05 KB NODE_PROFILING
react-dom.production.min.js 0.0% 🔺+0.1% 110.51 KB 110.56 KB 35.55 KB 35.58 KB UMD_PROD
ReactFire-dev.js +0.1% +0.1% 919.97 KB 920.54 KB 204.09 KB 204.23 KB FB_WWW_DEV
react-dom.profiling.min.js 0.0% +0.1% 113.84 KB 113.89 KB 36.59 KB 36.62 KB UMD_PROFILING
ReactFire-prod.js 0.0% 🔺+0.1% 363.32 KB 363.44 KB 66.39 KB 66.42 KB FB_WWW_PROD
react-dom.development.js +0.1% +0.1% 891.49 KB 892.05 KB 202.23 KB 202.39 KB NODE_DEV
ReactFire-profiling.js 0.0% 0.0% 370.22 KB 370.31 KB 67.7 KB 67.74 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% 0.0% 133.61 KB 133.61 KB 35.31 KB 35.31 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 110.59 KB 110.64 KB 35.14 KB 35.15 KB NODE_PROD
ReactDOM-prod.js 0.0% 0.0% 375.34 KB 375.46 KB 68.79 KB 68.82 KB FB_WWW_PROD
ReactDOMServer-prod.js 0.0% -0.0% 48.36 KB 48.36 KB 11.12 KB 11.12 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% 0.0% 382.27 KB 382.37 KB 70.1 KB 70.13 KB FB_WWW_PROFILING
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 3.88 KB 3.88 KB 1.51 KB 1.51 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 10.95 KB 10.95 KB 4 KB 4 KB UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.1% 1.21 KB 1.21 KB 706 B 705 B UMD_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactART-dev.js +0.1% +0.1% 568.04 KB 568.6 KB 118.78 KB 118.93 KB FB_WWW_DEV
react-art.development.js +0.1% +0.1% 624.25 KB 624.81 KB 136.68 KB 136.83 KB UMD_DEV
react-art.production.min.js 🔺+0.1% 🔺+0.1% 101.43 KB 101.48 KB 31.08 KB 31.1 KB UMD_PROD
react-art.development.js +0.1% +0.1% 555.13 KB 555.69 KB 119.31 KB 119.46 KB NODE_DEV
react-art.production.min.js 🔺+0.1% 🔺+0.1% 66.48 KB 66.54 KB 20.41 KB 20.43 KB NODE_PROD
ReactART-prod.js 🔺+0.1% 🔺+0.1% 216.79 KB 216.91 KB 36.78 KB 36.81 KB FB_WWW_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js +0.1% +0.1% 569 KB 569.56 KB 122.28 KB 122.43 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.1% 0.0% 67.83 KB 67.88 KB 20.85 KB 20.86 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.1% 564.54 KB 565.1 KB 121.11 KB 121.28 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.1% 67.55 KB 67.6 KB 20.61 KB 20.62 KB NODE_PROD
ReactTestRenderer-dev.js +0.1% +0.1% 579.65 KB 580.21 KB 121.41 KB 121.56 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% -0.0% 42.06 KB 42.06 KB 10.89 KB 10.89 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 11.88 KB 11.88 KB 3.7 KB 3.7 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactFabric-dev.js +0.1% +0.1% 691.42 KB 691.98 KB 146.74 KB 146.92 KB RN_FB_DEV
ReactFabric-prod.js 0.0% 🔺+0.1% 261.09 KB 261.21 KB 45 KB 45.03 KB RN_FB_PROD
ReactNativeRenderer-dev.js +0.1% +0.1% 702.57 KB 703.13 KB 149.34 KB 149.51 KB RN_OSS_DEV
ReactFabric-profiling.js 0.0% +0.1% 269.72 KB 269.81 KB 46.49 KB 46.52 KB RN_FB_PROFILING
ReactNativeRenderer-prod.js 0.0% 🔺+0.1% 268.77 KB 268.89 KB 46.23 KB 46.26 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js 0.0% +0.1% 276.5 KB 276.6 KB 47.76 KB 47.78 KB RN_OSS_PROFILING
ReactNativeRenderer-dev.js +0.1% +0.1% 702.66 KB 703.23 KB 149.39 KB 149.57 KB RN_FB_DEV
ReactNativeRenderer-prod.js 0.0% 🔺+0.1% 268.76 KB 268.88 KB 46.24 KB 46.27 KB RN_FB_PROD
ReactNativeRenderer-profiling.js 0.0% +0.1% 276.49 KB 276.59 KB 47.76 KB 47.79 KB RN_FB_PROFILING
ReactFabric-dev.js +0.1% +0.1% 691.32 KB 691.88 KB 146.7 KB 146.88 KB RN_OSS_DEV
ReactFabric-prod.js 0.0% 🔺+0.1% 261.08 KB 261.2 KB 44.99 KB 45.02 KB RN_OSS_PROD
ReactFabric-profiling.js 0.0% +0.1% 269.72 KB 269.82 KB 46.48 KB 46.51 KB RN_OSS_PROFILING

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-reflection.development.js 0.0% 0.0% 19.26 KB 19.26 KB 6.14 KB 6.14 KB NODE_DEV
react-reconciler-reflection.production.min.js 0.0% 🔺+0.2% 2.58 KB 2.58 KB 1.13 KB 1.13 KB NODE_PROD
react-reconciler-persistent.development.js +0.1% +0.1% 550.79 KB 551.35 KB 116.77 KB 116.93 KB NODE_DEV
react-reconciler-persistent.production.min.js 🔺+0.1% 🔺+0.1% 67.75 KB 67.8 KB 20.22 KB 20.24 KB NODE_PROD
react-reconciler.development.js +0.1% +0.1% 553.21 KB 553.77 KB 117.81 KB 117.96 KB NODE_DEV
react-reconciler.production.min.js 🔺+0.1% 🔺+0.1% 67.74 KB 67.79 KB 20.21 KB 20.23 KB NODE_PROD

react-refresh

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-refresh-runtime.development.js +7.3% +3.8% 16.89 KB 18.12 KB 5.3 KB 5.51 KB NODE_DEV
react-refresh-babel.production.min.js 0.0% 0.0% 6.82 KB 6.82 KB 2.38 KB 2.38 KB NODE_PROD

Generated by 🚫 dangerJS

@gaearon gaearon requested a review from sebmarkbage June 23, 2019 08:34
The check wasn't very resilient because in Concurrent Mode it looks like we can get further follow-up commits even if we captured an error. So we can't reliably distinguish the case where after an error you _manually_ rendered null.

Retrying on an edit after a tree failed _and_ you rendered null in the same tree seems fine. It's also very unlikely a pattern like this actually exists in the wild.
hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
} else {
hook.onCommitFiberRoot(rendererID, root);
hook.onCommitFiberRoot(rendererID, root, undefined, didError);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like we should pass priorityLevel and didError in both cases?

Copy link
Copy Markdown
Contributor

@bvaughn bvaughn Jun 24, 2019

Choose a reason for hiding this comment

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

Ignore me. I misread initially due to weird code wrapping combined with stupidity.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

(Resolved in a chat)

@gaearon gaearon merged commit d420d2c into facebook:master Jun 24, 2019
@gaearon gaearon deleted the retry-roots branch June 24, 2019 15:55
gaearon added a commit to gaearon/react that referenced this pull request Jun 24, 2019
* Retry failed roots on refresh

* Don't prevent retry after error -> render(null) special case

The check wasn't very resilient because in Concurrent Mode it looks like we can get further follow-up commits even if we captured an error. So we can't reliably distinguish the case where after an error you _manually_ rendered null.

Retrying on an edit after a tree failed _and_ you rendered null in the same tree seems fine. It's also very unlikely a pattern like this actually exists in the wild.
rickhanlonii pushed a commit to rickhanlonii/react that referenced this pull request Jun 25, 2019
* Retry failed roots on refresh

* Don't prevent retry after error -> render(null) special case

The check wasn't very resilient because in Concurrent Mode it looks like we can get further follow-up commits even if we captured an error. So we can't reliably distinguish the case where after an error you _manually_ rendered null.

Retrying on an edit after a tree failed _and_ you rendered null in the same tree seems fine. It's also very unlikely a pattern like this actually exists in the wild.
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.

4 participants