File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,12 @@ function createFinalResult(
121
121
componentName : string ,
122
122
throwJsErrors : boolean
123
123
) : null | string | Promise < RenderResult > {
124
+ // Node can handle multiple rendering requests simultaneously.
125
+ // Console history is stored globally in `console.history`.
126
+ // To prevent cross-request data leakage:
127
+ // 1. We build the consoleReplayScript here, before any async operations.
128
+ // 2. The console history is reset after the sync part of each request.
129
+ // This causes console logs happening during async operations to not be captured.
124
130
const consoleReplayScript = buildConsoleReplay ( ) ;
125
131
126
132
const { result } = renderState ;
@@ -163,7 +169,7 @@ function serverRenderReactComponentInternal(options: RenderParams): null | strin
163
169
164
170
// Finalize the rendering result and prepare it for server response
165
171
// 1. Builds the consoleReplayScript for client-side console replay
166
- // 2. Handles both synchronous and asynchronous (Promise) results
172
+ // 2. Extract the result from promise (if needed) by awaiting it
167
173
// 3. Constructs a JSON object with the following properties:
168
174
// - html: string | null (The rendered component HTML)
169
175
// - consoleReplayScript: string (Script to replay console outputs on the client)
You can’t perform that action at this time.
0 commit comments