From e0e9a37b0f0435f37d70925de54cd72f07904d50 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 2 Sep 2022 00:01:48 +0800 Subject: [PATCH] test: ignore stale process cleanup failures on Windows In some tests we try to clean up stale child processes on Windows, but they don't necessarily exist, in that case we should ignore any failures from the WMIC.exe command. --- test/common/child_process.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/common/child_process.js b/test/common/child_process.js index 30669821bf4165..22fb8190602966 100644 --- a/test/common/child_process.js +++ b/test/common/child_process.js @@ -12,7 +12,8 @@ function cleanupStaleProcess(filename) { } process.once('beforeExit', () => { const basename = filename.replace(/.*[/\\]/g, ''); - require('child_process') + try { + require('child_process') .execFileSync(`${process.env.SystemRoot}\\System32\\wbem\\WMIC.exe`, [ 'process', 'where', @@ -20,6 +21,9 @@ function cleanupStaleProcess(filename) { 'delete', '/nointeractive', ]); + } catch { + // Ignore failures, there might not be any stale process to clean up. + } }); }