fix(nodecg): include actionable diagnostics when process exits before readiness (#27)

This commit is contained in:
Pandipipas
2026-02-23 22:24:22 +01:00
committed by GitHub
parent 1f7b05e703
commit 4aa75802cc
2 changed files with 64 additions and 2 deletions
+43
View File
@@ -236,3 +236,46 @@ test("startNodeCG falla si el puerto ya está ocupado", async () => {
await manager.startNodecgProcess();
}, /ya está en uso/);
});
test("waitForNodeCGReady expone diagnóstico cuando NodeCG sale antes de readiness", async () => {
const child = new MockChildProcess(4242);
const manager = createNodecgProcessManager({
isDev: true,
nodecgRootPath: "/fake/nodecg",
nodecgBaseUrl: "http://127.0.0.1:9090",
appConfig: getBaseConfig(),
log: () => undefined,
deps: {
pathExists: () => true,
platform: "linux",
spawnProcess: () => child as unknown as import("node:child_process").ChildProcess,
fetchUrl: async () => {
child.emit("exit", 1, null);
throw new Error("still starting");
},
setTimer: (handler) => {
handler();
return 0;
},
stdoutWrite: () => undefined,
stderrWrite: () => undefined,
probePortAvailable: async () => true,
hasReadWriteAccess: () => true,
},
});
await manager.startNodecgProcess();
await assert.rejects(
async () => {
await manager.waitForNodecgReady(Date.now());
},
(error: unknown) => {
assert.ok(error instanceof Error);
assert.match(error.message, /NodeCG terminó antes de estar listo/);
assert.match(error.message, /Última salida registrada/);
assert.match(error.message, /Ruta NodeCG: \/fake\/nodecg/);
return true;
},
);
});