-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
[suspense][error handling] Inline renderRoot and fix error handling bug #16801
Merged
acdlite
merged 9 commits into
facebook:master
from
acdlite:refactor-and-fix-failing-test
Sep 23, 2019
Merged
[suspense][error handling] Inline renderRoot and fix error handling bug #16801
acdlite
merged 9 commits into
facebook:master
from
acdlite:refactor-and-fix-failing-test
Sep 23, 2019
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ReactDOM: size: 0.0%, gzip: 0.0% Details of bundled changes.Comparing: a87d245...d69643c react-art
react-native-renderer
react-reconciler
react-dom
react-test-renderer
|
sebmarkbage
approved these changes
Sep 23, 2019
Fixes a bug in the Scheduler profiler where the start time of a delayed tasks is always 0.
Covers an edge case where an error is thrown inside the complete phase of a component that is in the return path of a component that suspends. The second error should also be handled (i.e. able to be captured by an error boundary. The test is currently failing because there's a call to `completeUnitOfWork` inside the main render phase `catch` block. That call is not itself wrapped in try-catch, so anything that throws is treated as a fatal/unhandled error. I believe this bug is only observable if something in the host config throws; and, only in legacy mode, because in concurrent/batched mode, `completeUnitOfWork` on fiber that throws follows the "unwind" path only, not the "complete" path, and the "unwind" path does not call any host config methods.
I want to get rid of the the `isSync` argument to `renderRoot`, and instead use separate functions for concurrent and synchronous render. As a first step, this extracts the push/pop logic that happens before and after the render phase into helper functions.
Similar to previous commit. Extract error handling logic into a separate function so it can be reused.
Removes `isSync` argument in favor of separate functions.
Moving this out to avoid an accidental early return, which would bypass the call to `ensureRootIsScheduled` and freeze the UI.
Inlines `renderRoot` into `performConcurrentWorkOnRoot` and `performSyncWorkOnRoot`. This lets me remove the `isSync` argument and also get rid of a redundant try-catch wrapper.
Fatal errors (errors that are not captured by an error boundary) are currently rethrown from directly inside the render phase's `catch` block. This is a refactor hazard because the code in this branch has to mirror the code that happens at the end of the function, when exiting the render phase in the normal case. This commit moves the throw to the end, using a new root exit status.
acdlite
force-pushed
the
refactor-and-fix-failing-test
branch
from
September 23, 2019 18:15
d1d5fef
to
d69643c
Compare
This was referenced Oct 5, 2019
This was referenced Apr 1, 2020
This was referenced Apr 11, 2020
This was referenced Apr 21, 2020
This was referenced May 2, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to work loop refactor in #16743.
After the recent changes, the
isSync
argument torenderRoot
is only used in a single place, to determine whether to callworkLoop
orworkLoopSync
. All other forked behavior was lifted intoperformConcurrentWorkOnRoot
andperformSyncWorkOnRoot
. So, this goes one step further and inlinesrenderRoot
into its callers.Most of the changes here are copy-pasting and moving stuff around. The high level flow is essentially the same. I split the work into small commits to help with reviewing.
The final commit is unrelated, but I've included it because it fixes the test I added in #16800. The fix relies on the
handleError
function I extracted as part of this refactor PR. I could also submit a separate fix that's independent of this PR; however, since it's not a super urgent bug, and I was planning to do these refactors regardless, I think it's fine to group these.Fixes #16800