Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
12345678910111213141516171819202122232425262728// Ask real Node whether an open stdin holds each guest in tests/fixtures/stdin-liveness.mjs:// `node scripts/stdin-liveness.mjs` prints one JSON line per case, the literal// tests/stdin.spec.ts expects.import { spawn } from "node:child_process";import { BIG_INPUT_BYTES, CLOSE_AFTER_MS, INPUT, LIVENESS_CASES } from "../tests/fixtures/stdin-liveness.mjs";import { assertPinnedNode, oracleEnv } from "./pinned-node.mjs";
assertPinnedNode();
for (const [name, source] of Object.entries(LIVENESS_CASES)) { const child = spawn(process.execPath, ["-e", source], { stdio: ["pipe", "pipe", "inherit"], env: oracleEnv() }); let stdout = ""; let closed = false; let timer; child.stdout.on("data", (d) => { stdout += d; timer ??= setTimeout(() => { closed = true; child.stdin.end(); }, CLOSE_AFTER_MS); }); child.stdin.on("error", () => {}); // a child that exits early makes the big write EPIPE child.stdin.write(name === "fullBuffer" ? "x".repeat(BIG_INPUT_BYTES) : INPUT); const code = await new Promise((resolve) => child.on("exit", resolve)); clearTimeout(timer); console.log(JSON.stringify({ name, held: closed, code, stdout }));}