From 90b7facd52ffd9acc8ba4a5d608b27ef4bfae01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Tue, 27 Jun 2017 08:24:31 -0700 Subject: [PATCH] Don't use the render callback with promises (#10050) This covers up errors that are thrown in Fiber, because callback gets fired *and* an error is thrown. Created a follow up #10049 to reevaluate these semantics. # Conflicts: # scripts/fiber/tests-passing-except-dev.txt # scripts/fiber/tests-passing.txt --- scripts/fiber/tests-passing-except-dev.txt | 6 ------ scripts/fiber/tests-passing.txt | 6 ++++++ .../shared/__tests__/ReactDOMServerIntegration-test.js | 9 ++++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/fiber/tests-passing-except-dev.txt b/scripts/fiber/tests-passing-except-dev.txt index 4ae14d31d6..c91cd76d31 100644 --- a/scripts/fiber/tests-passing-except-dev.txt +++ b/scripts/fiber/tests-passing-except-dev.txt @@ -86,12 +86,6 @@ src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js * renders a div with a single child surrounded by whitespace with client render on top of bad server markup * renders >,<, and & as single child with client render on top of bad server markup * renders >,<, and & as multiple children with client render on top of bad server markup -* throws when rendering a string component with clean client render -* throws when rendering a string component with client render on top of bad server markup -* throws when rendering an undefined component with clean client render -* throws when rendering an undefined component with client render on top of bad server markup -* throws when rendering a number component with clean client render -* throws when rendering a number component with client render on top of bad server markup * renders an input with a value and an onChange with client render on top of bad server markup * renders an input with a value and readOnly with client render on top of bad server markup * renders an input with a value and no onChange/readOnly with client render on top of bad server markup diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt index b35828520a..bcf0ceec75 100644 --- a/scripts/fiber/tests-passing.txt +++ b/scripts/fiber/tests-passing.txt @@ -1206,8 +1206,14 @@ src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js * renders >,<, and & as multiple children with clean client render * renders >,<, and & as multiple children with client render on top of good server markup * throws when rendering a string component with server string render +* throws when rendering a string component with clean client render +* throws when rendering a string component with client render on top of bad server markup * throws when rendering an undefined component with server string render +* throws when rendering an undefined component with clean client render +* throws when rendering an undefined component with client render on top of bad server markup * throws when rendering a number component with server string render +* throws when rendering a number component with clean client render +* throws when rendering a number component with client render on top of bad server markup * throws when rendering null with server string render * throws when rendering null with clean client render * throws when rendering null with client render on top of bad server markup diff --git a/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js b/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js index 271d2f2d3f..64947e423e 100644 --- a/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js +++ b/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js @@ -28,9 +28,12 @@ const stream = require('stream'); // promisified version of ReactDOM.render() function asyncReactDOMRender(reactElement, domElement) { - return new Promise(resolve => - ReactDOM.render(reactElement, domElement, resolve), - ); + return new Promise(resolve => { + ReactDOM.render(reactElement, domElement); + // We can't use the callback for resolution because that will not catch + // errors. They're thrown. + resolve(); + }); } // performs fn asynchronously and expects count errors logged to console.error. // will fail the test if the count of errors logged is not equal to count.