From 20695c2a3a57b89de690af8d8599d6a6efd5c1ce Mon Sep 17 00:00:00 2001 From: leej3 <“johnleenimh@gmail.com> Date: Thu, 9 May 2024 10:37:58 +0000 Subject: [PATCH] kill persistent processes --- .github/workflows/ci_cd.yml | 22 ++++++++++++++++++++++ src/index.ts | 9 ++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 6967674..b2bf25d 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -394,6 +394,28 @@ jobs: expected: failure actual: ${{ steps.sad_path_timeout.outcome }} + - name: sad-path (timeout persistent) + id: sad_path_timeout_persistent + uses: ./ + continue-on-error: true + with: + timeout_seconds: 15 + max_attempts: 2 + command: | + node -e " + process.on('SIGTERM', () => {}); + setInterval(() => {}, 1000); + setTimeout(() => { process.exit(0); }, 60000); + " + - uses: nick-invision/assert-action@v1 + with: + expected: 2 + actual: ${{ steps.sad_path_timeout_persistent.outputs.total_attempts }} + - uses: nick-invision/assert-action@v1 + with: + expected: failure + actual: ${{ steps.sad_path_timeout_persistent.outcome }} + ci_integration_timeout_retry_on_timeout: name: Run Integration Timeout Tests (retry_on timeout) runs-on: ubuntu-latest diff --git a/src/index.ts b/src/index.ts index aa5642e..bdce66a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -93,7 +93,7 @@ async function runCmd(attempt: number, inputs: Inputs) { debug(`Signal: ${signal}`); // timeouts are killed manually - if (signal === 'SIGTERM') { + if (signal === 'SIGTERM' || signal === 'SIGKILL') { return; } @@ -117,6 +117,13 @@ async function runCmd(attempt: number, inputs: Inputs) { timeout = true; kill(child.pid); await retryWait(ms.seconds(inputs.retry_wait_seconds)); + + while (!done) { + debug(`Sending SIGKILL to process ${child.pid}`); + kill(child.pid, 'SIGKILL'); + await wait(ms.seconds(3)); + } + throw new Error(`Timeout of ${getTimeout(inputs)}ms hit`); } else if (exit > 0) { await retryWait(ms.seconds(inputs.retry_wait_seconds));