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

Improve error boundary handling for unmounted subtrees #19542

Merged

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Aug 5, 2020

A passive effect's cleanup function may throw after an unmount. Prior to this commit, such an error would be ignored. (React would not notify any error boundaries.) After this commit, React's behavior varies depending on which reconciler fork is being used.

Old reconciler fork

React will call componentDidCatch for the nearest unmounted error boundary (if there is one). If there are no unmounted error boundaries, React will still "swallow" the error because the return pointer has been disconnected so the normal error handling logic does not know how to traverse the tree to find the nearest still-mounted ancestor. (This behavior is not ideal, but it is temporary and will be replaced by the new fork.)

New reconciler fork

React will skip any unmounted boundaries and look for a still-mounted boundary. If one is found, it will call getDerivedStateFromError and/or componentDidCatch (depending on the type of boundary). Unmounted boundaries will be ignored, but as they have been unmounted– this seems appropriate.

Tests have been added for both reconciler variants. Note that syncing this change to www/fbsource might appear as a regression, because we may start logging errors that were previously ignored.

Open questions

  • Is the temporary fix in the old reconciler worth it? Should we just let it swallow errors for now until the new fork gets merged again?
  • Should we call gDSFE after an unmounted tree throws or should we only call cDC?
  • Is this bug (potentially) bad enough to warrant a v16 bugfix release?

@acdlite
Copy link
Collaborator

acdlite commented Aug 5, 2020

Could you open the old fork changes separately? I have lots of Opinions™ on the new fork solution, whereas I'm not really picky about the old fork at all. And the old fork is more urgent, to unblock the RN sync.

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 5, 2020

There's two changes to the old fork:

  1. Defer nulling out the stateNode field (so we don't throw).
  2. Call componentDidCatch inside of the unmounted tree (if we find a boundary).

Which changes are you suggesting being split out? just the first? or both?

@facebook-github-bot facebook-github-bot added React Core Team Opened by a member of the React Core Team CLA Signed labels Aug 5, 2020
@acdlite
Copy link
Collaborator

acdlite commented Aug 5, 2020

Which changes are you suggesting being split out? just the first? or both?

Sorry, I phrased it ambiguously. What I meant was, let's focus on unblocking the RN sync first. So just patch the old fork so it no longer throws an internal error.

Then, once we've mitigated the blocker, we can return to addressing root cause. I'm suggesting we do that in a separate PR since that involves a semantic discussion and will take longer.

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 5, 2020

Sure. I was under the impression that folks wanted the full fix now. I'll post the smalller one separately.

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 5, 2020

Unblock PR #19543

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 6, 2020

Okay. I think I have a reasonable proposal. Take a look when you get the chance. 😄

@bvaughn bvaughn marked this pull request as ready for review August 6, 2020 14:35
@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 6, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 3bfe779:

Sandbox Source
React Configuration

@gaearon
Copy link
Collaborator

gaearon commented Aug 6, 2020

skip any unmounted boundaries and look for a still-mounted boundary

I'm concerned this undermines the locality of error boundaries. For example, consider a buggy <FeedStoryCommentGifAttachment />. Luckily it's wrapped in an error boundary so even if it fails, the problem is isolated to that particular component inside a comment inside a story.

Now let's say we switch from Feed to Profile, and then the destroy handlers fire. There is a bug. But the closest common ancestor of <FeedStoryCommentGifAttachment /> and <Profile /> is <Router />. So even though the team "responsible" for the error are the folks maintaining the GIF renderer, it is the Profile that is being "penalized" by showing an error fallback over the whole page.

Arguably missing an error after unmount is not good. But by definition, since the component has unmounted, it means it isn't showing a broken UI. Therefore, I argue that it's not good to penalize non-broken UI that is perfectly capable of being rendered. We know it's not internally inconsistent — so why hide it?

Maybe there is a middle ground in that we don't set the gDSFE state, but we do call cDC for logging.

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 6, 2020

@gaearon Agreed that calling cDC only and ignoring gDSFE would be another reasonable proposal. Arguably better, although as Seb mentioned yesterday– there is some decreased pressure to fix errors that nobody "sees".

Fortunately, I think the component stack info (that's passed to componentDidCatch) makes it okay for us to call cDC on a higher (still-mounted) boundary. So the only question is about gDSFE.

@gaearon
Copy link
Collaborator

gaearon commented Aug 6, 2020

Yeah. Although there's a reason there's a decreased pressure if it doesn't lead to user-visible bugs. :-)

I think overall my intuition is that <CatchAll><Bug /></CatchAll> should always be safe to add without making the rest of your app behave in an unstable way. Otherwise it breaks encapsulation of responsibility.

@sebmarkbage
Copy link
Collaborator

An error that happens in renders are more ok to ignore because they’re not expected to have effects. In that case we can safely say that it’s better not to show the UI.

Errors that happen in effects are different though. They are expected to leave things in an inconsistent state.

There’s nothing to say that it’s actually isolated to that subtree. The unmount can affect other trees. Imaging refs or the similar thing in user space where the parent now has a reference to the deleted child.

React can’t really safely clean up even for mount or update effects by scoping it to the error boundary neither.

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 6, 2020

That's a good point.

If the effect did something like register/unregister itself with a common ancestor and it threw during unregistration, that could leave the larger app in a broken state (not confined to a subtree like an error thrown during render).

As you mention though, this affects mounts and updates too. So maybe that adds weight to the argument that we should at least match behaviors there (and call gDSFE too)?

Even if gDSFE isn't guaranteed to leave the app in a not-broken state, at least it makes the errors more in-your-face.

@sebmarkbage
Copy link
Collaborator

sebmarkbage commented Aug 6, 2020

I think it’s at least a strong indicator that we must do something since it is a potentially really bad bug.

We could log only. However we know that there is a lot of variability in if logs are logged correctly, how seriously people follow up on logs or even if logging is done at all.

Also if we don’t show anything to the user, there isn’t something that indicates to the user that they should be careful. Like maybe they shouldn’t be so confident in future uses of the page or maybe they should reload.

I think that’s together is a pretty strong argument that the UI should change in some way. Now it could maybe change in other ways. Maybe there’s a way to isolate it or make it consistent. But seems like UI needs to change one way or another just to indicate that something on the page is not fully ok.

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 6, 2020

Is this bug (potentially) bad enough to warrant a v16 bugfix release?

I guess that would be a more difficult thing to do, since the real fix is only in the new reconciler fork.

@acdlite
Copy link
Collaborator

acdlite commented Aug 6, 2020

Is this bug (potentially) bad enough to warrant a v16 bugfix release?

My opinion is no, unless someone complains about it. It's been this way for a long time. It predates hooks even because errors inside componentWillUnmount raise the same semantic issue.

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 6, 2020

Yeah, I didn't think so– but it seemed worth discussing explicitly.

@bvaughn bvaughn force-pushed the improve-error-handling-for-unmounted-tree branch from 8527595 to 9aafde8 Compare August 7, 2020 12:34
@sizebot
Copy link

sizebot commented Aug 7, 2020

Details of bundled changes.

Comparing: dab0854...3bfe779

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js +0.1% +0.1% 876.9 KB 877.66 KB 200.81 KB 201.03 KB NODE_DEV
ReactDOMForked-prod.js 🔺+0.2% 🔺+0.2% 391.18 KB 392.16 KB 71.95 KB 72.09 KB FB_WWW_PROD
react-dom.production.min.js 🔺+0.1% 0.0% 119.27 KB 119.39 KB 38.32 KB 38.33 KB NODE_PROD
ReactDOMForked-profiling.js +0.2% +0.2% 406.24 KB 407.16 KB 74.65 KB 74.79 KB FB_WWW_PROFILING
react-dom-test-utils.production.min.js 0.0% -0.0% 12.86 KB 12.86 KB 5.04 KB 5.04 KB UMD_PROD
ReactDOMTesting-dev.js +0.1% +0.1% 949.1 KB 949.91 KB 212.66 KB 212.86 KB FB_WWW_DEV
ReactDOMTesting-prod.js 🔺+0.1% 🔺+0.1% 391.82 KB 392.14 KB 73.36 KB 73.41 KB FB_WWW_PROD
react-dom.development.js +0.1% +0.1% 921.34 KB 922.12 KB 203.3 KB 203.49 KB UMD_DEV
react-dom.production.min.js 🔺+0.1% 0.0% 119.22 KB 119.33 KB 38.97 KB 38.98 KB UMD_PROD
react-dom.profiling.min.js +0.1% +0.1% 123.12 KB 123.23 KB 40.19 KB 40.23 KB UMD_PROFILING
ReactDOMForked-dev.js 0.0% +0.1% 993.56 KB 994.05 KB 220.1 KB 220.21 KB FB_WWW_DEV
react-dom.profiling.min.js +0.1% 0.0% 123.34 KB 123.46 KB 39.58 KB 39.59 KB NODE_PROFILING
ReactDOM-dev.js +0.1% +0.1% 986.35 KB 987.16 KB 219.12 KB 219.31 KB FB_WWW_DEV
ReactDOM-prod.js 🔺+0.1% 🔺+0.1% 388.2 KB 388.52 KB 71.25 KB 71.3 KB FB_WWW_PROD
ReactDOM-profiling.js +0.1% +0.1% 402.39 KB 402.71 KB 73.91 KB 73.95 KB FB_WWW_PROFILING
ReactDOMServer-dev.js 0.0% 0.0% 146.97 KB 146.97 KB 37.34 KB 37.34 KB FB_WWW_DEV
ReactDOMServer-prod.js 0.0% -0.0% 47.3 KB 47.3 KB 11.04 KB 11.04 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% -0.0% 65.86 KB 65.86 KB 18.17 KB 18.17 KB UMD_DEV

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactART-prod.js 🔺+0.1% 🔺+0.1% 243.91 KB 244.24 KB 43 KB 43.05 KB FB_WWW_PROD
react-art.development.js +0.1% +0.1% 666.11 KB 666.89 KB 141.98 KB 142.17 KB UMD_DEV
react-art.production.min.js 🔺+0.1% 🔺+0.1% 109.66 KB 109.78 KB 33.95 KB 33.97 KB UMD_PROD
react-art.development.js +0.1% +0.2% 568.49 KB 569.24 KB 124.23 KB 124.44 KB NODE_DEV
react-art.production.min.js 🔺+0.2% 🔺+0.1% 74.62 KB 74.74 KB 23.12 KB 23.15 KB NODE_PROD
ReactART-dev.js +0.1% +0.2% 632.26 KB 633.07 KB 134.25 KB 134.46 KB FB_WWW_DEV

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js +0.1% +0.2% 684.43 KB 685.24 KB 148.3 KB 148.53 KB RN_FB_DEV
ReactFabric-dev.js +0.1% +0.2% 665.15 KB 665.96 KB 143.66 KB 143.89 KB RN_FB_DEV
ReactNativeRenderer-dev.js +0.1% +0.2% 679.04 KB 679.85 KB 147.45 KB 147.67 KB RN_OSS_DEV
ReactFabric-prod.js 🔺+0.1% 🔺+0.1% 265.64 KB 265.96 KB 47.06 KB 47.09 KB RN_FB_PROD
ReactNativeRenderer-prod.js 🔺+0.1% 🔺+0.1% 271.84 KB 272.16 KB 48.34 KB 48.39 KB RN_OSS_PROD
ReactFabric-profiling.js +0.1% +0.1% 276.99 KB 277.31 KB 49.24 KB 49.29 KB RN_FB_PROFILING
ReactNativeRenderer-profiling.js +0.1% +0.1% 283.33 KB 283.66 KB 50.52 KB 50.57 KB RN_OSS_PROFILING
ReactNativeRenderer-prod.js 🔺+0.1% 🔺+0.1% 271.79 KB 272.12 KB 48.33 KB 48.37 KB RN_FB_PROD
ReactNativeRenderer-profiling.js +0.1% +0.1% 283.29 KB 283.61 KB 50.5 KB 50.55 KB RN_FB_PROFILING
ReactFabric-dev.js +0.1% +0.2% 659.75 KB 660.56 KB 142.8 KB 143.03 KB RN_OSS_DEV
ReactFabric-prod.js 🔺+0.1% 🔺+0.1% 265.67 KB 265.99 KB 47.07 KB 47.1 KB RN_OSS_PROD
ReactFabric-profiling.js +0.1% +0.1% 277.03 KB 277.35 KB 49.26 KB 49.31 KB RN_OSS_PROFILING

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +0.1% +0.2% 624.25 KB 625 KB 133.89 KB 134.1 KB NODE_DEV
react-reconciler.production.min.js 🔺+0.1% 🔺+0.1% 84.1 KB 84.22 KB 25.85 KB 25.87 KB NODE_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% 604.6 KB 605.38 KB 127.26 KB 127.45 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.1% 76.79 KB 76.9 KB 24.01 KB 24.02 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.2% 576.01 KB 576.77 KB 125.81 KB 126.02 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.1% 76.6 KB 76.72 KB 23.72 KB 23.74 KB NODE_PROD
ReactTestRenderer-dev.js +0.1% +0.2% 591.34 KB 592.14 KB 126.97 KB 127.19 KB FB_WWW_DEV
ReactTestRenderer-dev.js +0.1% +0.2% 585.99 KB 586.8 KB 126.7 KB 126.91 KB RN_FB_DEV
ReactTestRenderer-prod.js 🔺+0.1% 🔺+0.1% 231.22 KB 231.54 KB 42.03 KB 42.08 KB RN_FB_PROD
ReactTestRenderer-profiling.js +0.1% +0.1% 242.61 KB 242.93 KB 44.19 KB 44.24 KB RN_FB_PROFILING

ReactDOM: size: 0.0%, gzip: -0.0%

Size changes (stable)

Generated by 🚫 dangerJS against 3bfe779

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 10, 2020

Ping 😄 Can I get a review?

@sebmarkbage
Copy link
Collaborator

sebmarkbage commented Aug 10, 2020

I acknowledge your desire and will attempt to look at this, this afternoon. If I don’t, feel free to message me directly at an uncomfortable time of the day.

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 11, 2020

When would the most uncomfortable time of day be, for you? 😇

@bvaughn bvaughn force-pushed the improve-error-handling-for-unmounted-tree branch from 9aafde8 to 7467f51 Compare August 13, 2020 13:20
@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 13, 2020

Okay Seb. Back to you.

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 13, 2020

Not sure why DOMPluginEventSystem-test.internal.js test started failing after I merged master into my branch. Seems like that should be unrelated. Will dig in...

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 13, 2020

Ooh. I think this PR actually catches a legit error from one of our other tests 😄

One of the DOM plugin event system tests calls its click handles during unmount without any params:

setClick1();
setClick2();
setClick3();
setClick4();

Which triggers an invariant that we were (before) just ignoring:

return (
target: EventTarget | ReactScopeInstance,
callback: (SyntheticEvent<EventTarget>) => void,
) => {
invariant(
typeof callback === 'function',
'ReactDOM.createEventHandle: setter called with an invalid ' +
'callback. The callback must be a function.',
);

@bvaughn bvaughn force-pushed the improve-error-handling-for-unmounted-tree branch 2 times, most recently from 46dc286 to f1958e2 Compare August 13, 2020 19:03
A passive effect's cleanup function may throw after an unmount. Prior to this commit, such an error would be ignored. (React would not notify any error boundaries.) After this commit, React's behavior varies depending on which reconciler fork is being used.

For the old reconciler, React will call componentDidCatch for the nearest unmounted error boundary (if there is one). If there are no unmounted error boundaries, React will still swallow the error because the return pointer has been disconnected, so the normal error handling logic does not know how to traverse the tree to find the nearest still-mounted ancestor.

For the new reconciler, React will skip any unmounted boundaries and look for a still-mounted boundary. If one is found, it will call getDerivedStateFromError and/or componentDidCatch (depending on the type of boundary).

Tests have been added for both reconciler variants for now.
@bvaughn bvaughn force-pushed the improve-error-handling-for-unmounted-tree branch from f1958e2 to 3bfe779 Compare August 13, 2020 19:14
if (sourceFiber.tag === HostRoot) {
// Error was thrown at the root. There is no parent, so the root
// itself should capture it.
captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
return;
}

let fiber = sourceFiber.return;
let fiber = nearestMountedAncestor;
Copy link
Contributor Author

@bvaughn bvaughn Aug 13, 2020

Choose a reason for hiding this comment

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

This is the main fix for the new fork. The rest of the changes were just to funnel this fiber through.

});

// @gate new
it('should use the nearest still-mounted boundary if there are no unmounted boundaries', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test covers the error-boundary-as-immediate-parent case.

Copy link
Collaborator

@sebmarkbage sebmarkbage left a comment

Choose a reason for hiding this comment

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

Looks great!

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 14, 2020

Thanks!

@bvaughn bvaughn merged commit ffb749c into facebook:master Aug 14, 2020
@bvaughn bvaughn deleted the improve-error-handling-for-unmounted-tree branch August 14, 2020 20:47
@acdlite
Copy link
Collaborator

acdlite commented Aug 15, 2020

This fix looks great!

We should add the same behavior for errors thrown in componentWillUnmount, too. It'll be the same fix: in commitUnmount, pass the parent of the nearest mounted boundary, instead of current.return:

safelyCallDestroy(current, current.return, destroy);

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 15, 2020

Thanks @acdlite.

I'm not aware of this being a problem for cWU, since we have not yet disconnected the return pointer at that point (cWU is called by commitDeletion before it calls detachFiberMutation). So errors thrown in cWU can still walk the return path to find the nearest boundary (the same as layout effects can).

Am I mistaken about something?

Edit 1: Oh I believe what you're suggesting is that we should make this change so that if the nearest error boundary happens to be one we are about to unmount– we'll skip over it. In which case, yes! That's a good suggestion. I'll be happy to make the change on Monday.

Edit 2: Seems like we should get that change into v17 along with the passive effects change, so we're consistent. I'll make it on Monday.

facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Oct 27, 2020
Summary:
This sync includes the following changes:
- **[eaaf4cbce](facebook/react@eaaf4cbce )**: 17.0.1 //<Dan Abramov>//
- **[6f62abb58](facebook/react@6f62abb58 )**: Remove usage of Array#fill ([#20071](facebook/react#20071)) //<Dan Abramov>//
- **[40cfe1f48](facebook/react@40cfe1f48 )**: Update CHANGELOG.md //<Dan Abramov>//
- **[f021a983a](facebook/react@f021a983a )**: Bump versions for 17 ([#20062](facebook/react#20062)) //<Dan Abramov>//
- **[d1bb4d851](facebook/react@d1bb4d851 )**: Profiler: Include ref callbacks in onCommit duration ([#20060](facebook/react#20060)) //<Brian Vaughn>//
- **[c59c3dfe5](facebook/react@c59c3dfe5 )**: useRef: Warn about reading or writing mutable values during render ([#18545](facebook/react#18545)) //<Brian Vaughn>//
- **[7b6cac952](facebook/react@7b6cac952 )**: Improved Profiler commit hooks test ([#20053](facebook/react#20053)) //<Brian Vaughn>//
- **[dfb6a4033](facebook/react@dfb6a4033 )**: [Fast Refresh] Fix crashes caused by rogue Proxies ([#20030](facebook/react#20030)) ([#20039](facebook/react#20039)) //<Kai Riemann>//
- **[37cb732c5](facebook/react@37cb732c5 )**: Use bitwise OR to define flag masks ([#20044](facebook/react#20044)) //<Andrew Clark>//
- **[eb3181e77](facebook/react@eb3181e77 )**: Add Visibility flag for hiding/unhiding trees ([#20043](facebook/react#20043)) //<Andrew Clark>//
- **[0dd809bdf](facebook/react@0dd809bdf )**: Remove last schedulePassiveEffectCallback call ([#20042](facebook/react#20042)) //<Andrew Clark>//
- **[8df7b7911](facebook/react@8df7b7911 )**: Remove Passive flag from "before mutation" phase ([#20038](facebook/react#20038)) //<Andrew Clark>//
- **[c57fe4a2c](facebook/react@c57fe4a2c )**: ReactIs.isValidElementType Unit Test extended with PureComponent case ([#20033](facebook/react#20033)) //<adasq>//
- **[02da938fd](facebook/react@02da938fd )**: Don't double-invoke effects in legacy roots ([#20028](facebook/react#20028)) //<Brian Vaughn>//
- **[d95c4938d](facebook/react@d95c4938d )**: [EventSystem] Revise onBeforeBlur propagation mechanics ([#20020](facebook/react#20020)) //<Dominic Gannaway>//
- **[f46a80ae1](facebook/react@f46a80ae1 )**: Update outdated links and fix two broken links  ([#19985](facebook/react#19985)) //<Saikat Guha>//
- **[0a4c7c565](facebook/react@0a4c7c565 )**: [Flight] Don't warn for key, but error for ref ([#19986](facebook/react#19986)) //<Sebastian Markbåge>//
- **[993ca533b](facebook/react@993ca533b )**: Enable eager listeners statically ([#19983](facebook/react#19983)) //<Dan Abramov>//
- **[40c52de96](facebook/react@40c52de96 )**: [Flight] Add Runtime Errors for Non-serializable Values ([#19980](facebook/react#19980)) //<Sebastian Markbåge>//
- **[1992d9730](facebook/react@1992d9730 )**: Revert "Temporarily disable Profiler commit hooks flag ([#19900](facebook/react#19900))" ([#19960](facebook/react#19960)) //<Brian Vaughn>//
- **[44d39c4d7](facebook/react@44d39c4d7 )**: Removed skip-error-boundaries modifications from old fork ([#19961](facebook/react#19961)) //<Brian Vaughn>//
- **[cc77be957](facebook/react@cc77be957 )**: Remove unnecessary error overriding in ([#19949](facebook/react#19949)) //<Paul Doyle>//
- **[97625272a](facebook/react@97625272a )**: Debug tracing tests for CPU bound suspense ([#19943](facebook/react#19943)) //<Brian Vaughn>//
- **[43363e279](facebook/react@43363e279 )**: Fix codestyle for typeof comparison ([#19928](facebook/react#19928)) //<Eugene Maslovich>//
- **[5427b4657](facebook/react@5427b4657 )**: Temporarily disable Profiler commit hooks flag ([#19900](facebook/react#19900)) //<Brian Vaughn>//
- **[1faf9e3dd](facebook/react@1faf9e3dd )**: Suspense for CPU-bound trees ([#19936](facebook/react#19936)) //<Andrew Clark>//
- **[7f08e908b](facebook/react@7f08e908b )**: Fix missing context to componentDidMount() when double-invoking lifecycles ([#19935](facebook/react#19935)) //<Brian Vaughn>//
- **[9198a5cec](facebook/react@9198a5cec )**: Refactor layout effect methods ([#19895](facebook/react#19895)) //<Brian Vaughn>//
- **[ba82eea38](facebook/react@ba82eea38 )**: Remove disableSchedulerTimeoutInWorkLoop flag ([#19902](facebook/react#19902)) //<Andrew Clark>//
- **[c63741fb3](facebook/react@c63741fb3 )**: offscreen double invoke effects ([#19523](facebook/react#19523)) //<Luna Ruan>//
- **[c6917346f](facebook/react@c6917346f )**: Fixed broken Profiler test ([#19894](facebook/react#19894)) //<Brian Vaughn>//
- **[87c023b1c](facebook/react@87c023b1c )**: Profiler onRender only called when we do work ([#19885](facebook/react#19885)) //<Brian Vaughn>//
- **[81aaee56a](facebook/react@81aaee56a )**: Don't call onCommit et al if there are no effects ([#19863](facebook/react#19863)) //<Andrew Clark>//
- **[7355bf575](facebook/react@7355bf575 )**: Consolidate commit phase hook functions ([#19864](facebook/react#19864)) //<Andrew Clark>//
- **[bc6b7b6b1](facebook/react@bc6b7b6b1 )**: Don't trigger lazy in DEV during element creation ([#19871](facebook/react#19871)) //<Dan Abramov>//
- **[a774502e0](facebook/react@a774502e0 )**: Use single quotes in getComponentName return ([#19873](facebook/react#19873)) //<Gustavo Saiani>//
- **[8b2d3783e](facebook/react@8b2d3783e )**: Use Passive flag to schedule onPostCommit ([#19862](facebook/react#19862)) //<Andrew Clark>//
- **[50d9451f3](facebook/react@50d9451f3 )**: Improve DevTools editing interface ([#19774](facebook/react#19774)) //<Brian Vaughn>//
- **[6fddca27e](facebook/react@6fddca27e )**: Remove passive intervention flag ([#19849](facebook/react#19849)) //<Dan Abramov>//
- **[36df9185c](facebook/react@36df9185c )**: chore(docs): Removed outdated comment about fb.me link  ([#19830](facebook/react#19830)) //<Adnaan Bheda>//
- **[16fb2b6f9](facebook/react@16fb2b6f9 )**: Moved resetChildLanes into complete work ([#19836](facebook/react#19836)) //<Brian Vaughn>//
- **[cc581065d](facebook/react@cc581065d )**: eslint-plugin-react-hooks@4.1.2 //<Dan Abramov>//
- **[0044805c8](facebook/react@0044805c8 )**: Update CHANGELOG.md //<Dan Abramov>//
- **[0f70d4dd6](facebook/react@0f70d4dd6 )**: Consider components in jsx as missing dependencies in typescript-eslint/parser@4.x ([#19815](facebook/react#19815)) //<Sebastian Silbermann>//
- **[84558c61b](facebook/react@84558c61b )**: Don't visit passive effects during layout phase ([#19809](facebook/react#19809)) //<Andrew Clark>//
- **[ad8a0a8cd](facebook/react@ad8a0a8cd )**: eslint-plugin-react-hooks@4.1.1 //<Dan Abramov>//
- **[77544a0d6](facebook/react@77544a0d6 )**: Update CHANGELOG.md //<Dan Abramov>//
- **[ed4fdfc73](facebook/react@ed4fdfc73 )**: test(eslint-plugin-react-hooks): Run with TS parsers >= 2.x ([#19792](facebook/react#19792)) //<Sebastian Silbermann>//
- **[cd75f93c0](facebook/react@cd75f93c0 )**: eslint-plugin-react-hooks: fix compatibility with typescript-eslint/parser@4.0.0+ ([#19751](facebook/react#19751)) //<Matthias Schiffer>//
- **[781212aab](facebook/react@781212aab )**: Remove double space in test name ([#19762](facebook/react#19762)) //<Gustavo Saiani>//
- **[e7b255341](facebook/react@e7b255341 )**: Internal `act`: Flush timers at end of scope ([#19788](facebook/react#19788)) //<Andrew Clark>//
- **[d17086c7c](facebook/react@d17086c7c )**: Decouple public, internal act implementation ([#19745](facebook/react#19745)) //<Andrew Clark>//
- **[d38ec17b1](facebook/react@d38ec17b1 )**: [Flight] Set dispatcher for duration of performWork() ([#19776](facebook/react#19776)) //<Joseph Savona>//
- **[4f3f7eeb7](facebook/react@4f3f7eeb7 )**: Bugfix: Effect clean up when deleting suspended tree ([#19752](facebook/react#19752)) //<Andrew Clark>//
- **[7baf9d412](facebook/react@7baf9d412 )**: Combine Flags and SubtreeFlags types ([#19775](facebook/react#19775)) //<Andrew Clark>//
- **[166544360](facebook/react@166544360 )**: Rename effect fields ([#19755](facebook/react#19755)) //<Andrew Clark>//
- **[708fa77a7](facebook/react@708fa77a7 )**: Decrease expiration time of input updates ([#19772](facebook/react#19772)) //<Andrew Clark>//
- **[36df483af](facebook/react@36df483af )**: Add feature flag to disable scheduler timeout in work loop ([#19771](facebook/react#19771)) //<Ricky>//
- **[bcc0aa463](facebook/react@bcc0aa463 )**: Revert "Revert "Remove onScroll bubbling flag ([#19535](facebook/react#19535))" ([#19655](facebook/react#19655))" ([#19761](facebook/react#19761)) //<Dan Abramov>//
- **[99cae887f](facebook/react@99cae887f )**: Add failing test for passive effect cleanup functions and memoized components ([#19750](facebook/react#19750)) //<Brian Vaughn>//
- **[2cfd73c4d](facebook/react@2cfd73c4d )**: Fix typo in comment (Noticable→Noticeable) ([#19737](facebook/react#19737)) //<Ikko Ashimine>//
- **[53e622ca7](facebook/react@53e622ca7 )**: Fix instances of function declaration after return ([#19733](facebook/react#19733)) //<Bhumij Gupta>//
- **[b7d18c4da](facebook/react@b7d18c4da )**: Support Babel's envName option in React Refresh plugin ([#19009](facebook/react#19009)) //<Kevin Weber>//
- **[1f38dcff6](facebook/react@1f38dcff6 )**: Remove withSuspenseConfig ([#19724](facebook/react#19724)) //<Andrew Clark>//
- **[1396e4a8f](facebook/react@1396e4a8f )**: Fixes eslint warning when node type is ChainExpression ([#19680](facebook/react#19680)) //<Pascal Fong Kye>//
- **[a8500be89](facebook/react@a8500be89 )**: Add `startTransition` as a known stable method ([#19720](facebook/react#19720)) //<Andrew Clark>//
- **[380dc95de](facebook/react@380dc95de )**: Revert "Append text string to <Text> error message ([#19581](facebook/react#19581))" ([#19723](facebook/react#19723)) //<Timothy Yung>//
- **[ddd1faa19](facebook/react@ddd1faa19 )**: Remove config argument from useTransition ([#19719](facebook/react#19719)) //<Andrew Clark>//
- **[92fcd46cc](facebook/react@92fcd46cc )**: Replace SuspenseConfig object with an integer ([#19706](facebook/react#19706)) //<Andrew Clark>//
- **[b754caaaf](facebook/react@b754caaaf )**: Enable eager listeners in open source ([#19716](facebook/react#19716)) //<Dan Abramov>//
- **[c1ac05215](facebook/react@c1ac05215 )**: [Flight] Support more element types and Hooks for Server and Hybrid Components ([#19711](facebook/react#19711)) //<Dan Abramov>//
- **[1eaafc9ad](facebook/react@1eaafc9ad )**: Clean up timeoutMs-related implementation details ([#19704](facebook/react#19704)) //<Andrew Clark>//
- **[8da0da093](facebook/react@8da0da093 )**: Disable timeoutMs argument ([#19703](facebook/react#19703)) //<Andrew Clark>//
- **[60ba723bf](facebook/react@60ba723bf )**: Add SuspenseList to devTools ([#19684](facebook/react#19684)) //<Ben Pernick>//
- **[5564f2c95](facebook/react@5564f2c95 )**: Add React.startTransition ([#19696](facebook/react#19696)) //<Ricky>//
- **[c4e0768d7](facebook/react@c4e0768d7 )**: Remove unused argument from `finishConcurrentRender` ([#19689](facebook/react#19689)) //<inottn>//
- **[848bb2426](facebook/react@848bb2426 )**: Attach Listeners Eagerly to Roots and Portal Containers ([#19659](facebook/react#19659)) //<Dan Abramov>//
- **[d2e914ab4](facebook/react@d2e914ab4 )**: Remove remaining references to effect list ([#19673](facebook/react#19673)) //<Andrew Clark>//
- **[d6e433899](facebook/react@d6e433899 )**: Use Global Render Timeout for CPU Suspense ([#19643](facebook/react#19643)) //<Sebastian Markbåge>//
- **[64ddef44c](facebook/react@64ddef44c )**: Revert "Remove onScroll bubbling flag ([#19535](facebook/react#19535))" ([#19655](facebook/react#19655)) //<Dan Abramov>//
- **[dd651df05](facebook/react@dd651df05 )**: Keep onTouchStart, onTouchMove, and onWheel passive ([#19654](facebook/react#19654)) //<Dan Abramov>//
- **[b8fa09e9e](facebook/react@b8fa09e9e )**: provide profiling bundle for react-reconciler ([#19559](facebook/react#19559)) //<Julien Gilli>//
- **[23595ff59](facebook/react@23595ff59 )**: Add missing param to safelyCallDestroy() ([#19638](facebook/react#19638)) //<Brian Vaughn>//
- **[ee409ea3b](facebook/react@ee409ea3b )**: change destroy to safelyCallDestroy ([#19605](facebook/react#19605)) //<Luna Ruan>//
- **[bcca5a6ca](facebook/react@bcca5a6ca )**: Always skip unmounted/unmounting error boundaries ([#19627](facebook/react#19627)) //<Brian Vaughn>//
- **[1a41a196b](facebook/react@1a41a196b )**: Append text string to <Text> error message ([#19581](facebook/react#19581)) //<Timothy Yung>//
- **[e4afb2fdd](facebook/react@e4afb2fdd )**: eslint-plugin-react-hooks@4.1.0 //<Dan Abramov>//
- **[ced05c46c](facebook/react@ced05c46c )**: Update CHANGELOG.md //<Dan Abramov>//
- **[702fad4b1](facebook/react@702fad4b1 )**: refactor fb.me redirect link to reactjs.org/link ([#19598](facebook/react#19598)) //<CY Lim>//
- **[49cd77d24](facebook/react@49cd77d24 )**: fix: leak strict mode with UMD builds ([#19614](facebook/react#19614)) //<Toru Kobayashi>//
- **[ffb749c95](facebook/react@ffb749c95 )**: Improve error boundary handling for unmounted subtrees ([#19542](facebook/react#19542)) //<Brian Vaughn>//
- **[9b35dd2fc](facebook/react@9b35dd2fc )**: Permanently removed component stacks from scheduling profiler data ([#19615](facebook/react#19615)) //<Brian Vaughn>//
- **[3f8115cdd](facebook/react@3f8115cdd )**: Remove `didTimeout` check from work loop //<Andrew Clark>//
- **[9abc2785c](facebook/react@9abc2785c )**: Remove wasteful checks from `shouldYield` //<Andrew Clark>//
- **[1d5e10f70](facebook/react@1d5e10f70 )**: [eslint-plugin-react-hooks] Report constant constructions ([#19590](facebook/react#19590)) //<Jordan Eldredge>//
- **[dab0854c5](facebook/react@dab0854c5 )**: Move commit passive unmount/mount to CommitWork ([#19599](facebook/react#19599)) //<Sebastian Markbåge>//
- **[ccb6c3945](facebook/react@ccb6c3945 )**: Remove unused argument ([#19600](facebook/react#19600)) //<inottn>//
- **[629125555](facebook/react@629125555 )**: [Scheduler] Re-throw unhandled errors ([#19595](facebook/react#19595)) //<Andrew Clark>//
- **[b8ed6a1aa](facebook/react@b8ed6a1aa )**: [Scheduler] Call postTask directly ([#19551](facebook/react#19551)) //<Andrew Clark>//
- **[ce37bfad5](facebook/react@ce37bfad5 )**: Remove resolutions from test renderer package.json ([#19577](facebook/react#19577)) //<Dan Abramov>//
- **[2704bb537](facebook/react@2704bb537 )**: Add ReactVersion to SchedulingProfiler render scheduled marks ([#19553](facebook/react#19553)) //<Kartik Choudhary>//
- **[0c52e24cb](facebook/react@0c52e24cb )**: Support inner component _debugOwner in memo ([#19556](facebook/react#19556)) //<Brian Vaughn>//
- **[0cd9a6de5](facebook/react@0cd9a6de5 )**: Parallelize Jest in CI ([#19552](facebook/react#19552)) //<Andrew Clark>//
- **[a63893ff3](facebook/react@a63893ff3 )**: Warn about undefined return value for memo and forwardRef ([#19550](facebook/react#19550)) //<Brian Vaughn>//
- **[32ff42868](facebook/react@32ff42868 )**: Add feature flag for setting update lane priority ([#19401](facebook/react#19401)) //<Ricky>//
- **[5bdd4c8c6](facebook/react@5bdd4c8c6 )**: Remove unused argument from call to jest method ([#19546](facebook/react#19546)) //<Gustavo Saiani>//
- **[a5fed98a9](facebook/react@a5fed98a9 )**: Register more node types that are used later as JSXIdentifiers ([#19514](facebook/react#19514)) //<Mateusz Burzyński>//
- **[f77c7b9d7](facebook/react@f77c7b9d7 )**: Re-add discrete flushing timeStamp heuristic (behind flag) ([#19540](facebook/react#19540)) //<Dominic Gannaway>//

Changelog: [general] [feature] Upgrade to React 17

Reviewed By: cpojer

Differential Revision: D24491201

fbshipit-source-id: c947da9dcccbd614e9dc58f3339b63e24829aca7
koto pushed a commit to koto/react that referenced this pull request Jun 15, 2021
A passive effect's cleanup function may throw after an unmount. Prior to this commit, such an error would be ignored. (React would not notify any error boundaries.) After this commit, React's behavior varies depending on which reconciler fork is being used.

For the old reconciler, React will call componentDidCatch for the nearest unmounted error boundary (if there is one). If there are no unmounted error boundaries, React will still swallow the error because the return pointer has been disconnected, so the normal error handling logic does not know how to traverse the tree to find the nearest still-mounted ancestor.

For the new reconciler, React will skip any unmounted boundaries and look for a still-mounted boundary. If one is found, it will call getDerivedStateFromError and/or componentDidCatch (depending on the type of boundary).

Tests have been added for both reconciler variants for now.
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.

6 participants