Skip to content

Commit 647f05c

Browse files
committed
[history] fix process.on memory leak
1 parent 0ca5dbe commit 647f05c

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/history/scripts/checkPackages.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,13 @@ export default function checkPackages(
190190
}
191191
}
192192

193-
process.on("SIGINT", async () => {
194-
await Promise.all(workers.map((worker) => worker.terminate()));
195-
reject(new Error("SIGINT"));
196-
});
193+
process.on("SIGINT", kill);
194+
}).finally(() => {
195+
process.off("SIGINT", kill);
197196
});
197+
198+
async function kill() {
199+
await Promise.all(workers.map((worker) => worker.terminate()));
200+
throw new Error("SIGINT");
201+
}
198202
}

0 commit comments

Comments
 (0)