From 3f6204203c71ac052dd7793c66de396897363393 Mon Sep 17 00:00:00 2001 From: Hendrik Liebau Date: Wed, 24 Jul 2024 23:26:26 +0200 Subject: [PATCH] Don't call `waitForReference` for initialized chunks --- .../react-client/src/ReactFlightClient.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/react-client/src/ReactFlightClient.js b/packages/react-client/src/ReactFlightClient.js index d1f1c8884a465..dedbfcc255dcd 100644 --- a/packages/react-client/src/ReactFlightClient.js +++ b/packages/react-client/src/ReactFlightClient.js @@ -1004,14 +1004,22 @@ function getOutlinedModel( for (let i = 1; i < path.length; i++) { value = value[path[i]]; if (value.$$typeof === REACT_LAZY_TYPE) { - return waitForReference( - value._payload, - parentObject, - key, - response, - map, - path.slice(i), - ); + const referencedChunk: SomeChunk = value._payload; + if (referencedChunk.status === INITIALIZED) { + value = referencedChunk.value; + } else if ( + referencedChunk.status === BLOCKED || + referencedChunk.status === PENDING + ) { + return waitForReference( + referencedChunk, + parentObject, + key, + response, + map, + path.slice(i), + ); + } } } const chunkValue = map(response, value);