fix(agent-pod): use process.exitCode not process.exit() in coordinator.js

process.exit() right after console.log() can drop buffered stdout when it's piped (not a TTY) -- exactly kubectl exec's case. Explains the silent empty-output-exit-1 failures. process.exitCode + natural exit lets the event loop drain and flush first.
This commit is contained in:
Story Crater Bot
2026-08-18 19:13:07 -07:00
parent 67e55ec868
commit 1a4160b3de
@@ -810,12 +810,18 @@ data:
"usage: coordinator.js --repo <url> [--tasks T0.1,T0.2;T1.1,T1.2,...] [--base main] [--branch <name>]\n" +
" --tasks omitted: discovers phases from the cloned repo's own tasks/INDEX.md"
);
process.exit(1);
// process.exitCode + natural exit, not process.exit() -- stdout piped
// through kubectl exec (not a TTY) can drop buffered console.log/
// console.error output if the process exits before it flushes. Setting
// exitCode and letting the event loop drain naturally is the
// documented-safe way to exit with a specific code without racing it.
process.exitCode = 1;
return;
}
const phases = opts.tasks ? opts.tasks.split(";").map((phase) => phase.split(",")) : null;
const pipelineId = require("node:crypto").randomUUID();
const result = await runPipeline({ pipelineId, repo: opts.repo, baseBranch: opts.base, tasks: phases, branchName: opts.branch });
process.exit(result.status === "completed" ? 0 : 1);
process.exitCode = result.status === "completed" ? 0 : 1;
}
if (require.main === module) {