Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,22 @@ function wakeChunkIfInitialized<T>(
rejectListeners.splice(rejectionIdx, 1);
}
}
// The status might have changed after fulfilling the reference.
switch ((chunk: SomeChunk<T>).status) {
case INITIALIZED:
const initializedChunk: InitializedChunk<T> = (chunk: any);
wakeChunk(
resolveListeners,
initializedChunk.value,
initializedChunk,
);
return;
case ERRORED:
if (rejectListeners !== null) {
rejectChunk(rejectListeners, chunk.reason);
}
return;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2196,4 +2196,29 @@ describe('ReactFlightDOMEdge', () => {
'Switched to client rendering because the server rendering errored:\n\nssr-throw',
);
});

it('should properly resolve with deduped objects', async () => {
const obj = {foo: 'hi'};

function Test(props) {
return props.obj.foo;
}

const root = {
obj: obj,
node: <Test obj={obj} />,
};

const stream = ReactServerDOMServer.renderToReadableStream(root);

const response = ReactServerDOMClient.createFromReadableStream(stream, {
serverConsumerManifest: {
moduleMap: null,
moduleLoading: null,
},
});

const result = await response;
expect(result).toEqual({obj: obj, node: 'hi'});
});
});
Loading