From 15acbaa8e147f6da64d11393c412d392274a0464 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Tue, 20 Dec 2016 15:34:44 -0800 Subject: [PATCH] Handle errors thrown when committing root Previously this caused an infinite loop. --- scripts/fiber/tests-passing.txt | 1 + .../shared/fiber/ReactFiberScheduler.js | 162 +++++++++--------- .../ReactIncrementalErrorHandling-test.js | 7 + 3 files changed, 89 insertions(+), 81 deletions(-) diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt index 2e0037fb7f..9a72e473b6 100644 --- a/scripts/fiber/tests-passing.txt +++ b/scripts/fiber/tests-passing.txt @@ -1184,6 +1184,7 @@ src/renderers/shared/fiber/__tests__/ReactIncrementalErrorHandling-test.js * unmounts components with uncaught errors * does not interrupt unmounting if detaching a ref throws * handles error thrown by host config while working on failed root +* handles error thrown by top-level callback src/renderers/shared/fiber/__tests__/ReactIncrementalReflection-test.js * handles isMounted even when the initial render is deferred diff --git a/src/renderers/shared/fiber/ReactFiberScheduler.js b/src/renderers/shared/fiber/ReactFiberScheduler.js index 08be5dbfda..f9a8c87afa 100644 --- a/src/renderers/shared/fiber/ReactFiberScheduler.js +++ b/src/renderers/shared/fiber/ReactFiberScheduler.js @@ -117,7 +117,7 @@ module.exports = function(config : HostConfig(config : HostConfig(config : HostConfig(config : HostConfig(config : HostConfig(config : HostConfig(config : HostConfig(config : HostConfig(config : HostConfig { expect(() => ReactNoop.flush()).toThrow('Error in host config.'); }); }); + + it('handles error thrown by top-level callback', () => { + ReactNoop.render(
, () => { + throw new Error('Error!'); + }); + expect(() => ReactNoop.flush()).toThrow('Error!'); + }); });