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(
121121 componentName : string ,
122122 throwJsErrors : boolean
123123) : 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.
124130 const consoleReplayScript = buildConsoleReplay ( ) ;
125131
126132 const { result } = renderState ;
@@ -163,7 +169,7 @@ function serverRenderReactComponentInternal(options: RenderParams): null | strin
163169
164170 // Finalize the rendering result and prepare it for server response
165171 // 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
167173 // 3. Constructs a JSON object with the following properties:
168174 // - html: string | null (The rendered component HTML)
169175 // - consoleReplayScript: string (Script to replay console outputs on the client)
You can’t perform that action at this time.
0 commit comments