diff --git a/node_package/src/buildConsoleReplay.ts b/node_package/src/buildConsoleReplay.ts index 369efb81b..3f22b1061 100644 --- a/node_package/src/buildConsoleReplay.ts +++ b/node_package/src/buildConsoleReplay.ts @@ -15,8 +15,6 @@ export function consoleReplay(customConsoleHistory: typeof console['history'] | const consoleHistory = customConsoleHistory ?? console.history; // console.history is a global polyfill used in server rendering. - // Must use Array.isArray instead of instanceof Array the history array is defined outside the vm if node renderer is used. - // 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. // $FlowFixMe if (!(Array.isArray(consoleHistory))) { return ''; diff --git a/node_package/src/serverRenderReactComponent.ts b/node_package/src/serverRenderReactComponent.ts index 481e4676d..eaba44418 100644 --- a/node_package/src/serverRenderReactComponent.ts +++ b/node_package/src/serverRenderReactComponent.ts @@ -112,6 +112,10 @@ as a renderFunction and not a simple React Function Component.`); try { const awaitedRenderResult = await renderResult; + + // If replayServerAsyncOperationLogs node renderer config is enabled, the console.history will contain all logs happened during sync and async operations. + // If replayServerAsyncOperationLogs node renderer config is disabled, the console.history will be empty, because it will clear the history after the sync execution. + // If the config is disabled, we will return the logs accumulated during the sync execution only. const consoleHistoryAfterAsyncExecution = console.history; let consoleReplayScript = ''; if ((consoleHistoryAfterAsyncExecution?.length ?? 0) > (consoleHistoryAfterSyncExecution?.length ?? 0)) { @@ -119,6 +123,7 @@ as a renderFunction and not a simple React Function Component.`); } else { consoleReplayScript = buildConsoleReplay(consoleHistoryAfterSyncExecution); } + promiseResult = { html: awaitedRenderResult, consoleReplayScript,