Skip to content

Commit a423bf3

Browse files
tiny changes
1 parent a0e207f commit a423bf3

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,6 @@ def parse_result_and_replay_console_messages(result_string, render_options)
237237
if render_options.logging_on_server
238238
console_script = result["consoleReplayScript"]
239239
console_script_lines = console_script.split("\n")
240-
# Skip the first two lines (new line and opening <script> tag) and the last line (closing </script> tag)
241-
console_script_lines = console_script_lines[2..-2]
242240
# Regular expression to match console.log or console.error calls with SERVER prefix
243241
re = /console\.(?:log|error)\.apply\(console, \["\[SERVER\] (?<msg>.*)"\]\);/
244242
console_script_lines&.each do |line|

node_package/src/buildConsoleReplay.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ declare global {
99
}
1010
}
1111

12-
export function consoleReplay(customConsoleHistory: typeof console['history'] | undefined = undefined, skipFirstNumberOfMessages: number = 0): string {
12+
export function consoleReplay(customConsoleHistory: typeof console['history'] | undefined = undefined, numberOfMessagesToSkip: number = 0): string {
1313
// console.history is a global polyfill used in server rendering.
1414
const consoleHistory = customConsoleHistory ?? console.history;
1515

1616
if (!(Array.isArray(consoleHistory))) {
1717
return '';
1818
}
1919

20-
const lines = consoleHistory.slice(skipFirstNumberOfMessages).map(msg => {
20+
const lines = consoleHistory.slice(numberOfMessagesToSkip).map(msg => {
2121
const stringifiedList = msg.arguments.map(arg => {
2222
let val: string;
2323
try {
@@ -44,6 +44,6 @@ export function consoleReplay(customConsoleHistory: typeof console['history'] |
4444
return lines.join('\n');
4545
}
4646

47-
export default function buildConsoleReplay(customConsoleHistory: typeof console['history'] | undefined = undefined, skipFirstNumberOfMessages: number = 0): string {
48-
return RenderUtils.wrapInScriptTags('consoleReplayLog', consoleReplay(customConsoleHistory, skipFirstNumberOfMessages));
47+
export default function buildConsoleReplay(customConsoleHistory: typeof console['history'] | undefined = undefined, numberOfMessagesToSkip: number = 0): string {
48+
return RenderUtils.wrapInScriptTags('consoleReplayLog', consoleReplay(customConsoleHistory, numberOfMessagesToSkip));
4949
}

node_package/src/serverRenderReactComponent.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,10 @@ export const streamServerRenderedReactComponent = (options: RenderParams): Reada
239239
}
240240
});
241241

242-
ReactDOMServer.renderToPipeableStream(reactRenderingResult)
243-
.pipe(transformStream);
242+
ReactDOMServer.renderToPipeableStream(reactRenderingResult).pipe(transformStream);
244243

245244
renderResult = transformStream;
246-
} catch (e: unknown) {
245+
} catch (e) {
247246
if (throwJsErrors) {
248247
throw e;
249248
}

0 commit comments

Comments
 (0)