Skip to content

Commit e4cdb59

Browse files
author
Kamil Sobol
authored
Handle process not found error in e2e tests (#2154)
1 parent 63fb254 commit e4cdb59

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.changeset/polite-bats-wait.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/integration-tests/src/process-controller/execa_process_killer.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,18 @@ export const killExecaProcess = async (processInstance: ExecaChildProcess) => {
1414
// turns out killing child process on Windows is a huge PITA
1515
// https://stackoverflow.com/questions/23706055/why-can-i-not-kill-my-child-process-in-nodejs-on-windows
1616
// https://github.com/sindresorhus/execa#killsignal-options
17-
// eslint-disable-next-line spellcheck/spell-checker
18-
await execa('taskkill', ['/pid', `${processInstance.pid}`, '/f', '/t']);
17+
try {
18+
// eslint-disable-next-line spellcheck/spell-checker
19+
await execa('taskkill', ['/pid', `${processInstance.pid}`, '/f', '/t']);
20+
} catch (e) {
21+
// if process doesn't exist it means that it managed to exit gracefully by now.
22+
// so don't fail in that case.
23+
const isProcessNotFoundError =
24+
e instanceof Error && e.message.includes('not found');
25+
if (!isProcessNotFoundError) {
26+
throw e;
27+
}
28+
}
1929
} else {
2030
processInstance.kill('SIGINT');
2131
}

0 commit comments

Comments
 (0)