Skip to content

Commit

Permalink
chore(compas): prevent zombie processes
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkdev98 committed Aug 29, 2023
1 parent 4c4420a commit 896a29f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion docs/.vitepress/theme/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
--vp-c-green-2: #34d399;
--vp-c-green-3: #6ee7b7;
--vp-c-green-soft: rgba(16, 185, 129, 0.14);

}

.dark {
Expand Down
13 changes: 10 additions & 3 deletions packages/compas/src/main/development/integrations/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,19 @@ export class ActionsIntegration extends BaseIntegration {
* command: string[],
* workingDirectory: string,
* startTime: number,
* boundResetState: () => void,
* }}
*/
this.activeProcess = undefined;

const exitHandler = () => {
if (this.activeProcess?.cp) {
// @ts-expect-error
process.kill(this.activeProcess.cp.pid);
}
};

process.once("exit", exitHandler);

this.setActionsGroups();

if (this.state.screen.state === "idle") {
Expand Down Expand Up @@ -201,12 +209,11 @@ export class ActionsIntegration extends BaseIntegration {
cwd: action.workingDirectory,
stdio: ["ignore", "inherit", "inherit"],
}),
boundResetState: this.resetState.bind(this),
};

// Separate listeners for screen reset and user information
this.activeProcess.cp.once("exit", this.onActionExit.bind(this));
this.activeProcess.cp.once("exit", this.activeProcess.boundResetState);
this.activeProcess.cp.once("exit", this.resetState.bind(this));
}

async killAction() {
Expand Down

0 comments on commit 896a29f

Please sign in to comment.