Skip to content

Commit 1a5a7a3

Browse files
Refactor RSCServerRoot to use RailsContext in generateRSCPayload and improve error messaging for missing manifest files
1 parent 1c4abc4 commit 1a5a7a3

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

node_package/src/RSCServerRoot.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ declare global {
1010
function generateRSCPayload(
1111
componentName: string,
1212
props: Record<string, unknown>,
13-
serverSideRSCPayloadParameters: unknown,
13+
railsContext: RailsContext,
1414
): Promise<NodeJS.ReadableStream>;
1515
}
1616

@@ -76,11 +76,10 @@ const RSCServerRoot: RenderFunction = async (
7676
!railsContext?.reactServerClientManifestFileName
7777
) {
7878
throw new Error(
79-
`${
80-
'serverClientManifestFileName and reactServerClientManifestFileName are required. ' +
79+
'serverClientManifestFileName and reactServerClientManifestFileName are required. ' +
8180
'Please ensure that React Server Component webpack configurations are properly set ' +
82-
'as stated in the React Server Component tutorial. The received rails context is: '
83-
}${JSON.stringify(railsContext)}`,
81+
'as stated in the React Server Component tutorial. ' +
82+
'Ensure to use "stream_react_component" instead of "react_component" to SSR a server component.',
8483
);
8584
}
8685

@@ -96,11 +95,7 @@ const RSCServerRoot: RenderFunction = async (
9695
railsContext.reactServerClientManifestFileName,
9796
railsContext.reactClientManifestFileName,
9897
);
99-
const rscPayloadStream = await generateRSCPayload(
100-
componentName,
101-
componentProps,
102-
railsContext.serverSideRSCPayloadParameters,
103-
);
98+
const rscPayloadStream = await generateRSCPayload(componentName, componentProps, railsContext);
10499

105100
// Tee the stream to pass it to the server component and the payload container
106101
const rscPayloadStream1 = new PassThrough();

0 commit comments

Comments
 (0)