Skip to content

Commit

Permalink
Handle process not found error in e2e tests (#2154)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolk authored Oct 25, 2024
1 parent 63fb254 commit e4cdb59
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .changeset/polite-bats-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,18 @@ export const killExecaProcess = async (processInstance: ExecaChildProcess) => {
// turns out killing child process on Windows is a huge PITA
// https://stackoverflow.com/questions/23706055/why-can-i-not-kill-my-child-process-in-nodejs-on-windows
// https://github.com/sindresorhus/execa#killsignal-options
// eslint-disable-next-line spellcheck/spell-checker
await execa('taskkill', ['/pid', `${processInstance.pid}`, '/f', '/t']);
try {
// eslint-disable-next-line spellcheck/spell-checker
await execa('taskkill', ['/pid', `${processInstance.pid}`, '/f', '/t']);
} catch (e) {
// if process doesn't exist it means that it managed to exit gracefully by now.
// so don't fail in that case.
const isProcessNotFoundError =
e instanceof Error && e.message.includes('not found');
if (!isProcessNotFoundError) {
throw e;
}
}
} else {
processInstance.kill('SIGINT');
}
Expand Down

0 comments on commit e4cdb59

Please sign in to comment.