mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
fix(dsh-plugin-browserskill): report interrupt-killed commands as interrupted
A child killed via killFor (overlay interrupt) exits with a null code and empty output, which used to render as a duplicated 'bsk x failed: bsk x failed'. Report it as interrupted instead.
This commit is contained in:
@@ -187,6 +187,11 @@ export function parseBskJson(result: BskRunResult, commandLabel: string): unknow
|
||||
throw new BskError(`bsk ${commandLabel} timed out`, { timedOut: true });
|
||||
}
|
||||
const body = result.stdout.trim();
|
||||
// Killed by our own interrupt (SIGTERM from killFor), not by the abort path:
|
||||
// say so instead of doubling the generic label into the message.
|
||||
if (result.code === null && !result.aborted && !result.timedOut) {
|
||||
throw new BskError(`bsk ${commandLabel} was interrupted (process killed)`);
|
||||
}
|
||||
if (result.code !== 0) {
|
||||
let parsed: BskErrorBody | undefined;
|
||||
try {
|
||||
|
||||
@@ -117,6 +117,10 @@ describe("parseBskJson", () => {
|
||||
expect(() => parseBskJson({ ...base, code: 1, stderr: "boom" }, "x")).toThrow(/boom/);
|
||||
});
|
||||
|
||||
it("reports killed-by-interrupt children (null exit code) as interrupted", () => {
|
||||
expect(() => parseBskJson({ ...base, code: null }, "navigate")).toThrow(/interrupted/);
|
||||
});
|
||||
|
||||
it("reports timeouts distinctly", () => {
|
||||
expect(() => parseBskJson({ ...base, timedOut: true }, "x")).toThrow(/timed out/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user