Skip to content

Commit 40b155c

Browse files
committed
test(cli): log warm process stages on windows
1 parent 0830527 commit 40b155c

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎.github/workflows/checkfast-measure.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
run: bun run build
4747
- name: Measure cold vs warm, then the warm process tests
4848
shell: bash
49-
run: cd packages/cli && npx vitest run src/warmCheck.process.test.ts --maxWorkers=1 -t "prints what a cold" 2>&1 | tail -150
49+
run: cd packages/cli && npx vitest run src/warmCheck.process.test.ts --maxWorkers=1 -t "prints what a cold" 2>&1 | tail -150 || true; echo ===DBG; cat warm-dbg.log
5050
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
5151
if: always()
5252
with:

‎packages/cli/src/warmCheck.process.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function privateEnv(): Record<string, string> {
3131
HYPERFRAMES_NO_TELEMETRY: "1",
3232
DO_NOT_TRACK: "1",
3333
...(process.platform === "win32" ? { LOCALAPPDATA: base } : { XDG_RUNTIME_DIR: base }),
34+
HF_WARM_DBG: join(process.cwd(), "warm-dbg.log"),
3435
};
3536
}
3637

@@ -61,7 +62,7 @@ function run(args: string[], env: Record<string, string>) {
6162
stdio: ["ignore", "pipe", "pipe"],
6263
});
6364
let stdout = "";
64-
child.stdout.on("data", (data: Buffer) => (stdout += data.toString()));
65+
child.stdout.on("data", (data: Buffer) => { stdout += data.toString(); process.stderr.write(`[out ${child.pid}] ${data}`); });
6566
const tag = args[2] ?? args[0]!.split(/[\\/]/).pop();
6667
child.stderr.on("data", (d: Buffer) => process.stderr.write(`[${Date.now()} ${tag} pid=${child.pid}] ${d}`));
6768
child.once("close", (code) => process.stderr.write(`[${Date.now()} ${tag}] closed ${code}\n`));

‎packages/cli/src/warmCheck.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ import {
1616
type WarmRequest,
1717
} from "./warmCheckProtocol.js";
1818

19+
import { appendFileSync as __dbgAppend } from "node:fs";
20+
const __dbg = (m: string) => __dbgAppend(process.env.HF_WARM_DBG ?? "warm-dbg.log", `${Date.now()} ${process.pid} ${m}\n`);
21+
process.on("uncaughtException", (e) => __dbg(`uncaught ${e?.stack ?? e}`));
22+
process.on("unhandledRejection", (e) => __dbg(`unhandled ${(e as Error)?.stack ?? e}`));
23+
__dbg(`start argv=${JSON.stringify(process.argv)}`);
1924
const [idleMs = "0", ...checkArgs] = process.argv.slice(2);
2025
const endpoint = warmCheckEndpoint();
2126
if (!endpoint) process.exit(0);
@@ -42,6 +47,7 @@ async function serve(socket: Socket, request: WarmRequest): Promise<void> {
4247
const finish = (code: number) => {
4348
if (finished) return;
4449
finished = true;
50+
__dbg(`finish ${code} ${new Error().stack}`);
4551
socket.end(encodeFrame(Frame.Exit, String(code)), () => exit(code));
4652
};
4753
socket.on("close", () => {
@@ -53,7 +59,9 @@ async function serve(socket: Socket, request: WarmRequest): Promise<void> {
5359
finish(Number(code ?? process.exitCode ?? 0))) as typeof process.exit;
5460
process.chdir(request.cwd);
5561
process.argv = [process.execPath, request.script, ...request.argv];
62+
__dbg(`serving ${JSON.stringify(request.argv)}`);
5663
await import(new URL("./cli.js", import.meta.url).href);
64+
__dbg(`imported exitCode=${process.exitCode}`);
5765
setImmediate(() => finish(Number(process.exitCode ?? 0)));
5866
}
5967

@@ -132,4 +140,4 @@ server.on("error", (error: NodeJS.ErrnoException) => {
132140
});
133141

134142
listen();
135-
void prelaunchBrowserForCheck(checkArgs).catch(() => undefined);
143+
void prelaunchBrowserForCheck(checkArgs).then(() => __dbg('prelaunched'), (e) => __dbg(`prelaunch failed ${e?.stack ?? e}`));

0 commit comments

Comments
 (0)