Skip to content

Commit 16d4c72

Browse files
committed
fix: prevent double kills on clean in local mode
1 parent 1f48569 commit 16d4c72

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/npm/@amazeelabs/publisher/src/mode-local/tools/runner.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const run = (options: {
6464

6565
const result = new Promise<Result>((resolve) => {
6666
process.on('exit', (code): void => {
67+
options.controller.offCancel(kill);
6768
if (killSignal) {
6869
core.output$.next(
6970
`Command killed with ${killSignal} signal: "${options.command}"`,
@@ -109,7 +110,7 @@ export const run = (options: {
109110
throw new Error(`Failed to kill "${options.command}" process.`);
110111
};
111112

112-
options.controller?.onCancel(() => kill());
113+
options.controller.onCancel(kill);
113114

114115
return {
115116
output,

packages/npm/@amazeelabs/publisher/src/tools/queue.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ export class TaskController {
66
onCancel = (callback: () => void): void => {
77
this.cancelCallbacks.push(callback);
88
};
9+
offCancel = (callback: () => void): void => {
10+
this.cancelCallbacks = this.cancelCallbacks.filter(cb => cb !== callback);
11+
};
912
}
1013

1114
export type TaskResult = Promise<boolean>;

0 commit comments

Comments
 (0)