From 8fdb1d0f55cedfb56af93bcc07daf5bbee655d38 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 1 Jun 2026 08:49:03 +0200 Subject: [PATCH] fix(e2e): stream Parallels fresh logs --- scripts/e2e/parallels/npm-update-smoke.ts | 13 +++++-------- test/scripts/parallels-npm-update-smoke.test.ts | 13 +++++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/scripts/e2e/parallels/npm-update-smoke.ts b/scripts/e2e/parallels/npm-update-smoke.ts index e63a6821a95..e392c59b30f 100755 --- a/scripts/e2e/parallels/npm-update-smoke.ts +++ b/scripts/e2e/parallels/npm-update-smoke.ts @@ -1,7 +1,7 @@ #!/usr/bin/env -S pnpm tsx import { spawn } from "node:child_process"; import { appendFileSync, readFileSync, writeFileSync } from "node:fs"; -import { readFile, rm, writeFile } from "node:fs/promises"; +import { readFile, rm } from "node:fs/promises"; import path from "node:path"; import { pathToFileURL } from "node:url"; import { @@ -638,28 +638,25 @@ class NpmUpdateSmoke { onOutput: (text: string) => void = () => undefined, ): Promise { return new Promise((resolve, reject) => { + writeFileSync(logPath, "", "utf8"); const child = spawn(command, args, { cwd: repoRoot, env: { ...process.env, ...env }, stdio: ["ignore", "pipe", "pipe"], }); - let log = ""; child.stdout.on("data", (chunk: Buffer) => { const text = chunk.toString("utf8"); - log += text; + appendFileSync(logPath, text, "utf8"); onOutput(text); }); child.stderr.on("data", (chunk: Buffer) => { const text = chunk.toString("utf8"); - log += text; + appendFileSync(logPath, text, "utf8"); onOutput(text); }); child.on("error", reject); child.on("close", (code) => { - void (async () => { - await writeFile(logPath, log, "utf8"); - resolve(code ?? 1); - })(); + resolve(code ?? 1); }); }); } diff --git a/test/scripts/parallels-npm-update-smoke.test.ts b/test/scripts/parallels-npm-update-smoke.test.ts index 9ee06012156..dba325914a9 100644 --- a/test/scripts/parallels-npm-update-smoke.test.ts +++ b/test/scripts/parallels-npm-update-smoke.test.ts @@ -77,6 +77,19 @@ describe("parallels npm update smoke", () => { expect(updateBlock).not.toContain("log += text"); }); + it("streams fresh lane logs instead of retaining them in memory", () => { + const script = readFileSync(SCRIPT_PATH, "utf8"); + const spawnLoggedBlock = script.slice( + script.indexOf(" private spawnLogged"), + script.indexOf(" private async monitorJobs"), + ); + + expect(spawnLoggedBlock).toContain('writeFileSync(logPath, "", "utf8")'); + expect(spawnLoggedBlock).toContain("appendFileSync(logPath, text"); + expect(spawnLoggedBlock).not.toContain("let log"); + expect(spawnLoggedBlock).not.toContain("log += text"); + }); + it("runs Windows updates through a detached done-file runner", () => { const script = readFileSync(SCRIPT_PATH, "utf8"); const transports = readFileSync(GUEST_TRANSPORTS_PATH, "utf8");