Fizz: Prevent UnhandledPromiseRejection if shell errors (#24043)
Sebastian Silbermann committed
Mar 8, 2022 at 15:13 UTC
a59f53a603306777fc6f949d84ce85f09bba4e4c
1 file changed
+4
packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
+4
@@ -67,6 +67,10 @@ function renderToReadableStream(
67
resolve(stream);
68
}
69
function onShellError(error: mixed) {
70
+ // If the shell errors the caller of `renderToReadableStream` won't have access to `allReady`.
71
+ // However, `allReady` will be rejected by `onFatalError` as well.
72
+ // So we need to catch the duplicate, uncatchable fatal error in `allReady` to prevent a `UnhandledPromiseRejection`.
73
+ allReady.catch(() => {});
74
reject(error);
75
}
76
const request = createRequest(