From d52a7cbae61e609a7d21d278ad84426c7dde773f Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Tue, 10 Nov 2020 19:05:47 -0500 Subject: [PATCH] Add failing test for serialization errors not being caught by inner boundary --- .../src/__tests__/ReactFlight-test.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/packages/react-client/src/__tests__/ReactFlight-test.js b/packages/react-client/src/__tests__/ReactFlight-test.js index 3d4ccf5c459f1..325c2fc2a6352 100644 --- a/packages/react-client/src/__tests__/ReactFlight-test.js +++ b/packages/react-client/src/__tests__/ReactFlight-test.js @@ -228,6 +228,49 @@ describe('ReactFlight', () => { }); }); + it('should trigger the inner most error boundary when serialization fails', () => { + function ClientComponent({children}) { + // This should catch the error thrown by the server component, even though it has already happened. + // We currently need to wrap it in a div because as it's set up right now, a lazy reference will + // throw during reconciliation which will trigger the parent of the error boundary. + // This is similar to how these will suspend the parent if it's a direct child of a Suspense boundary. + // That's a bug. + return ( + +
{children}
+
+ ); + } + + const ClientComponentReference = moduleReference(ClientComponent); + + function Server() { + return ( + +
+ + ); + } + + const data = ReactNoopFlightServer.render(); + + function Client({transport}) { + return ReactNoopFlightClient.read(transport); + } + + act(() => { + ReactNoop.render( + + + , + ); + }); + }); + it('should warn in DEV if a toJSON instance is passed to a host component', () => { expect(() => { const transport = ReactNoopFlightServer.render(