Skip to content
This repository was archived by the owner on Sep 7, 2026. It is now read-only.

Commit 51437d9

Browse files
committed
fix(cli-agent-bridge): preserve config cleanup failures
1 parent 05bfcff commit 51437d9

2 files changed

Lines changed: 27 additions & 20 deletions

File tree

‎plugins/Hylouis233/cli-agent-bridge/server.mjs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ async function readBackendConfiguration(file, options = {}) {
317317
});
318318
if (options.cancel?.controller === controller) options.cancel.controller = null;
319319
if (result.treeTerminated !== true) {
320-
throw new Error(
320+
throw new BackendConfigurationCleanupError(
321321
"backend configuration reader cleanup could not be confirmed: " +
322322
(result.terminationError || "process tree termination was unconfirmed"),
323323
);
@@ -354,7 +354,8 @@ export async function loadBackends(options = {}) {
354354
try {
355355
return await readBackendConfiguration(file, options);
356356
} catch (error) {
357-
if (error instanceof OperationCancelledError || error instanceof DeadlineExceededError) {
357+
if (error instanceof OperationCancelledError || error instanceof DeadlineExceededError ||
358+
error instanceof BackendConfigurationCleanupError) {
358359
throw error;
359360
}
360361
throw new Error("cannot load explicit backend configuration " + file + ": " + error.message);
@@ -364,7 +365,8 @@ export async function loadBackends(options = {}) {
364365
try {
365366
return await readBackendConfiguration(bundled, options);
366367
} catch (error) {
367-
if (error instanceof OperationCancelledError || error instanceof DeadlineExceededError) {
368+
if (error instanceof OperationCancelledError || error instanceof DeadlineExceededError ||
369+
error instanceof BackendConfigurationCleanupError) {
368370
throw error;
369371
}
370372
return FALLBACK_BACKENDS;
@@ -1294,6 +1296,7 @@ function snapshotFailure(label, result) {
12941296
class OperationCancelledError extends Error {}
12951297
class DeadlineExceededError extends Error {}
12961298
class InvalidArgumentsError extends Error {}
1299+
class BackendConfigurationCleanupError extends Error {}
12971300
class GitProcessTreeUnconfirmedError extends Error {
12981301
constructor(label, terminationError, quarantine = null) {
12991302
super(label + " process tree could not be confirmed terminated: " + terminationError);

‎plugins/Hylouis233/cli-agent-bridge/tests/server.test.mjs‎

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,6 @@ test("backend configuration cleanup uncertainty outranks cancellation", async (c
13221322
stall: process.env.CLI_AGENT_BRIDGE_TEST_BACKEND_CONFIG_READ_STALL_FILE,
13231323
};
13241324
process.env.NODE_ENV = "test";
1325-
process.env.CLI_AGENT_BRIDGE_BACKENDS = config;
13261325
process.env.CLI_AGENT_BRIDGE_TEST_BACKEND_CONFIG_READ_STALL_FILE = path.join(root, "unused");
13271326
context.after(() => {
13281327
if (saved.nodeEnv === undefined) delete process.env.NODE_ENV;
@@ -1332,22 +1331,27 @@ test("backend configuration cleanup uncertainty outranks cancellation", async (c
13321331
if (saved.stall === undefined) delete process.env.CLI_AGENT_BRIDGE_TEST_BACKEND_CONFIG_READ_STALL_FILE;
13331332
else process.env.CLI_AGENT_BRIDGE_TEST_BACKEND_CONFIG_READ_STALL_FILE = saved.stall;
13341333
});
1335-
const cancel = testCancellation();
1336-
await assert.rejects(loadBackends({
1337-
cancel,
1338-
commandRunner: async () => {
1339-
cancel.cancel();
1340-
return {
1341-
treeTerminated: false,
1342-
terminationError: "fixture cleanup uncertainty",
1343-
timedOut: false,
1344-
exitCode: 0,
1345-
stderr: "",
1346-
stdout: "{}",
1347-
stdoutTruncated: false,
1348-
};
1349-
},
1350-
}), /cleanup could not be confirmed.*fixture cleanup uncertainty/iu);
1334+
for (const explicitOverride of [true, false]) {
1335+
if (explicitOverride) process.env.CLI_AGENT_BRIDGE_BACKENDS = config;
1336+
else delete process.env.CLI_AGENT_BRIDGE_BACKENDS;
1337+
const cancel = testCancellation();
1338+
await assert.rejects(loadBackends({
1339+
cancel,
1340+
commandRunner: async () => {
1341+
cancel.cancel();
1342+
return {
1343+
treeTerminated: false,
1344+
terminationError: "fixture cleanup uncertainty",
1345+
timedOut: false,
1346+
exitCode: 0,
1347+
stderr: "",
1348+
stdout: "{}",
1349+
stdoutTruncated: false,
1350+
};
1351+
},
1352+
}), /cleanup could not be confirmed.*fixture cleanup uncertainty/iu,
1353+
explicitOverride ? "explicit override" : "bundled configuration");
1354+
}
13511355
});
13521356

13531357
test("an unset backend override still loads the bundled configuration", async (context) => {

0 commit comments

Comments
 (0)