From 38861fda8955dc06de70401067772de338fb2a9e Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Fri, 30 Jun 2023 15:10:43 -0400 Subject: [PATCH] fix(js): ignore watch errors when a process is already killed on Windows (#17891) (cherry picked from commit 9bb60a7fc644c58b52261183874a0ebbda044ac3) --- packages/js/src/executors/node/lib/kill-tree.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/js/src/executors/node/lib/kill-tree.ts b/packages/js/src/executors/node/lib/kill-tree.ts index 71e6c24656642..2a28254e6c13d 100644 --- a/packages/js/src/executors/node/lib/kill-tree.ts +++ b/packages/js/src/executors/node/lib/kill-tree.ts @@ -18,7 +18,11 @@ export async function killTree(pid: number, signal: NodeJS.Signals) { switch (process.platform) { case 'win32': - exec('taskkill /pid ' + pid + ' /T /F', callback); + exec('taskkill /pid ' + pid + ' /T /F', (error) => { + // Ignore Fatal errors (128) because it might be due to the process already being killed. + // On Linux/Mac we can check ESRCH (no such process), but on Windows we can't. + callback(error?.code !== 128 ? error : null); + }); break; case 'darwin': buildProcessTree(