Skip to content

Commit

Permalink
tiny changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AbanoubGhadban committed Oct 20, 2024
1 parent 2810ada commit 00d547f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ def parse_result_and_replay_console_messages(result_string, render_options)
if render_options.logging_on_server
console_script = result["consoleReplayScript"]
console_script_lines = console_script.split("\n")
# Skip the first two lines (new line and opening <script> tag) and the last line (closing </script> tag)
console_script_lines = console_script_lines[2..-2]
# Regular expression to match console.log or console.error calls with SERVER prefix
re = /console\.(?:log|error)\.apply\(console, \["\[SERVER\] (?<msg>.*)"\]\);/
console_script_lines&.each do |line|
Expand Down
8 changes: 4 additions & 4 deletions node_package/src/buildConsoleReplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ declare global {
}
}

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

if (!(Array.isArray(consoleHistory))) {
return '';
}

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

export default function buildConsoleReplay(customConsoleHistory: typeof console['history'] | undefined = undefined, skipFirstNumberOfMessages: number = 0): string {
return RenderUtils.wrapInScriptTags('consoleReplayLog', consoleReplay(customConsoleHistory, skipFirstNumberOfMessages));
export default function buildConsoleReplay(customConsoleHistory: typeof console['history'] | undefined = undefined, numberOfMessagesToSkip: number = 0): string {
return RenderUtils.wrapInScriptTags('consoleReplayLog', consoleReplay(customConsoleHistory, numberOfMessagesToSkip));
}
5 changes: 2 additions & 3 deletions node_package/src/serverRenderReactComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,10 @@ export const streamServerRenderedReactComponent = (options: RenderParams): Reada
}
});

ReactDOMServer.renderToPipeableStream(reactRenderingResult)
.pipe(transformStream);
ReactDOMServer.renderToPipeableStream(reactRenderingResult).pipe(transformStream);

renderResult = transformStream;
} catch (e: unknown) {
} catch (e) {
if (throwJsErrors) {
throw e;
}
Expand Down

0 comments on commit 00d547f

Please sign in to comment.