Skip to content

Commit a39a0f4

Browse files
committed
fix: capture exit event if the process is killed
1 parent 39e35c8 commit a39a0f4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

.changeset/blue-mugs-end.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"phpstan-vscode": patch
3+
---
4+
5+
Fix memory leak when the process is killed

src/utils/process.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export async function killProcess(p: ChildProcess) {
1313
export async function waitForClose(childProcess: ChildProcess) {
1414
return new Promise<number | null>((resolve, reject) => {
1515
childProcess.on("error", reject);
16+
childProcess.on("exit", (exitCode) => {
17+
if (childProcess.killed) resolve(exitCode);
18+
});
1619
childProcess.on("close", (exitCode) => resolve(exitCode));
1720
});
1821
}

0 commit comments

Comments
 (0)