diff --git a/lib/internal/test_runner/harness.js b/lib/internal/test_runner/harness.js index 88b028749b2d82..3680776a1071a7 100644 --- a/lib/internal/test_runner/harness.js +++ b/lib/internal/test_runner/harness.js @@ -126,11 +126,16 @@ function setup(root) { } }; + const terminationHandler = () => { + exitHandler(); + process.exit(); + } + process.on('uncaughtException', exceptionHandler); process.on('unhandledRejection', rejectionHandler); process.on('beforeExit', exitHandler); - process.on('SIGINT', exitHandler); - process.on('SIGTERM', exitHandler); + process.on('SIGINT', terminationHandler); + process.on('SIGTERM', terminationHandler); root.reporter.pipe(process.stdout); root.reporter.version(); diff --git a/test/parallel/test-runner-exit-code.js b/test/parallel/test-runner-exit-code.js index 187ab24c4893dc..12a4764858174e 100644 --- a/test/parallel/test-runner-exit-code.js +++ b/test/parallel/test-runner-exit-code.js @@ -2,6 +2,7 @@ require('../common'); const assert = require('assert'); const { spawnSync } = require('child_process'); +const { setTimeout } = require('timers/promises'); if (process.argv[2] === 'child') { const test = require('node:test'); @@ -18,7 +19,7 @@ if (process.argv[2] === 'child') { } else if (process.argv[3] === 'never_ends') { assert.strictEqual(process.argv[3], 'never_ends'); test('never ending test', () => { - return new Promise(() => {}); + return setTimeout(100_000_000); }); process.kill(process.pid, 'SIGINT'); }