diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index bc94a7a980..320705b695 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -110,6 +110,8 @@ jobs: - name: Tests uses: nick-fields/retry@v3 if: ${{ !steps.release-check.outputs.IS_RELEASE }} + env: + NODE_OPTIONS: -r ${{ github.workspace }}/kill-instrumentation.cjs with: timeout_minutes: 30 max_attempts: 3 @@ -221,6 +223,7 @@ jobs: # split tests across multiple machines CI_NODE_INDEX: ${{ matrix.machine }} CI_NODE_TOTAL: 4 + NODE_OPTIONS: -r ${{ github.workspace }}/kill-instrumentation.cjs with: timeout_minutes: 30 max_attempts: 3 diff --git a/kill-instrumentation.cjs b/kill-instrumentation.cjs new file mode 100644 index 0000000000..ceb976bf89 --- /dev/null +++ b/kill-instrumentation.cjs @@ -0,0 +1,20 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const childProcess = require('child_process') + +const origSpawn = childProcess.spawn +childProcess.spawn = (...args1) => { + const process = origSpawn.apply(childProcess, args1) + + const origKill = process.kill + process.kill = (...args2) => { + const stack = new Error('kill stack 2').stack + try { + return origKill.apply(process, args2) + } catch (error) { + console.log('Error in kill', stack) + throw error + } + } + + return process +} diff --git a/patches/execa+5.1.1.patch b/patches/execa+5.1.1.patch index 5d19016cd7..27f8d28826 100644 --- a/patches/execa+5.1.1.patch +++ b/patches/execa+5.1.1.patch @@ -6,7 +6,7 @@ index 287a142..bf71811 100644 }; const setKillTimeout = (kill, signal, options, killResult) => { -+ const stack = new Error('kill stack').stack; ++ const stack = new Error('kill stack 1').stack; if (!shouldForceKill(signal, options, killResult)) { return; } @@ -17,7 +17,7 @@ index 287a142..bf71811 100644 + try { + kill('SIGKILL'); + } catch (error) { -+ console.log('Error in kill timeout', error); ++ console.log('Error in kill timeout', stack); + throw e + } }, timeout);