Skip to content

Commit 86d4262

Browse files
add comment about clearing console history
1 parent 4caf257 commit 86d4262

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

node_package/src/serverRenderReactComponent.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,15 @@ function serverRenderReactComponentInternal(options: RenderParams): null | strin
181181
}
182182

183183
const serverRenderReactComponent: typeof serverRenderReactComponentInternal = (options) => {
184-
let result: string | Promise<RenderResult> | null = null;
185184
try {
186-
result = serverRenderReactComponentInternal(options);
185+
return serverRenderReactComponentInternal(options);
187186
} finally {
188187
// Reset console history after each render.
189188
// See `RubyEmbeddedJavaScript.console_polyfill` for initialization.
190-
// We don't need to clear the console history if the result is a promise
191-
// Promises only supported in node renderer and node renderer takes care of cleanining console history
192-
if (typeof result === 'string') {
193-
console.history = [];
194-
}
189+
// This is necessary when ExecJS and old versions of node renderer are used.
190+
// New versions of node renderer reset the console history automatically.
191+
console.history = [];
195192
}
196-
return result;
197193
};
198194

199195
export default serverRenderReactComponent;

0 commit comments

Comments
 (0)