fix(application): harden replay and process cleanup

This commit is contained in:
N0zoM1z0
2026-07-14 20:37:04 +00:00
parent c240ae19c6
commit b5dc7b70ec
16 changed files with 620 additions and 61 deletions
+9 -1
View File
@@ -18,7 +18,13 @@ const dependencies = (
serve,
writeStderr: (text) => output.push(text),
setExitCode: (code) => exitCodes.push(code),
registerShutdown: (handler) => shutdown.push(handler),
registerShutdown: (handler) => {
shutdown.push(handler);
return () => {
const index = shutdown.indexOf(handler);
if (index >= 0) shutdown.splice(index, 1);
};
},
});
describe("MCP runtime errors", () => {
@@ -52,6 +58,7 @@ describe("MCP runtime errors", () => {
shutdown[0]?.();
await nextTurn();
expect(closeCalls).toBe(1);
expect(shutdown).toEqual([]);
});
it("reports transport startup failure without its cause", async () => {
@@ -87,6 +94,7 @@ describe("MCP runtime errors", () => {
);
shutdown[0]?.();
await nextTurn();
expect(shutdown).toEqual([]);
expect(exitCodes).toEqual([1]);
expect(output).toEqual([
"REA could not close cleanly. End the REA process before starting it again.\n",