Skip to content

Commit c72f369

Browse files
add comments
1 parent 78c050c commit c72f369

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

node_package/src/buildConsoleReplay.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export function consoleReplay(customConsoleHistory: typeof console['history'] |
1515
const consoleHistory = customConsoleHistory ?? console.history;
1616

1717
// console.history is a global polyfill used in server rendering.
18-
// Must use Array.isArray instead of instanceof Array the history array is defined outside the vm if node renderer is used.
19-
// In this case, the Array prototype used to define the array is not the same as the one in the global scope inside the vm.
2018
// $FlowFixMe
2119
if (!(Array.isArray(consoleHistory))) {
2220
return '';

node_package/src/serverRenderReactComponent.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,18 @@ as a renderFunction and not a simple React Function Component.`);
112112

113113
try {
114114
const awaitedRenderResult = await renderResult;
115+
116+
// If replayServerAsyncOperationLogs node renderer config is enabled, the console.history will contain all logs happened during sync and async operations.
117+
// If replayServerAsyncOperationLogs node renderer config is disabled, the console.history will be empty, because it will clear the history after the sync execution.
118+
// If the config is disabled, we will return the logs accumulated during the sync execution only.
115119
const consoleHistoryAfterAsyncExecution = console.history;
116120
let consoleReplayScript = '';
117121
if ((consoleHistoryAfterAsyncExecution?.length ?? 0) > (consoleHistoryAfterSyncExecution?.length ?? 0)) {
118122
consoleReplayScript = buildConsoleReplay(consoleHistoryAfterAsyncExecution);
119123
} else {
120124
consoleReplayScript = buildConsoleReplay(consoleHistoryAfterSyncExecution);
121125
}
126+
122127
promiseResult = {
123128
html: awaitedRenderResult,
124129
consoleReplayScript,

0 commit comments

Comments
 (0)