From 4208deb90331945468ff4f6549adf697c7e228ee Mon Sep 17 00:00:00 2001 From: markthree <1801982702@qq.com> Date: Sat, 1 Apr 2023 20:05:40 +0800 Subject: [PATCH] fix: Cancel child processes only when reporting errors --- src/process.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/process.ts b/src/process.ts index 8fbee44..c4febdf 100644 --- a/src/process.ts +++ b/src/process.ts @@ -27,7 +27,11 @@ export async function execa(cmd: string[]) { }); // Prevent accidental exit - global.addEventListener("beforeunload", () => { + globalThis.addEventListener("error", () => { + childExit(); + }); + + globalThis.addEventListener("unhandledrejection", () => { childExit(); });