From f7ce5c669dbd3c75536bc9aaca84be10e69ef24f Mon Sep 17 00:00:00 2001 From: Charmander <~@charmander.me> Date: Sat, 12 Apr 2025 01:29:22 -0700 Subject: [PATCH] =?UTF-8?q?test:=20Avoid=20silencing=20errors=20from=20idl?= =?UTF-8?q?e=20timeout=20test=E2=80=99s=20child=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This hid the error fixed in #3263, for example. --- packages/pg-pool/test/idle-timeout.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/pg-pool/test/idle-timeout.js b/packages/pg-pool/test/idle-timeout.js index 0bb097565..3996255d2 100644 --- a/packages/pg-pool/test/idle-timeout.js +++ b/packages/pg-pool/test/idle-timeout.js @@ -89,14 +89,15 @@ describe('idle timeout', () => { it('unrefs the connections and timeouts so the program can exit when idle when the allowExitOnIdle option is set', function (done) { const child = fork(path.join(__dirname, 'idle-timeout-exit.js'), [], { - silent: true, + stdio: ['ignore', 'pipe', 'inherit', 'ipc'], env: { ...process.env, ALLOW_EXIT_ON_IDLE: '1' }, }) let result = '' child.stdout.setEncoding('utf8') child.stdout.on('data', (chunk) => (result += chunk)) child.on('error', (err) => done(err)) - child.on('close', () => { + child.on('exit', (exitCode) => { + expect(exitCode).to.equal(0) expect(result).to.equal('completed first\ncompleted second\n') done() }) @@ -104,13 +105,14 @@ describe('idle timeout', () => { it('keeps old behavior when allowExitOnIdle option is not set', function (done) { const child = fork(path.join(__dirname, 'idle-timeout-exit.js'), [], { - silent: true, + stdio: ['ignore', 'pipe', 'inherit', 'ipc'], }) let result = '' child.stdout.setEncoding('utf8') child.stdout.on('data', (chunk) => (result += chunk)) child.on('error', (err) => done(err)) - child.on('close', () => { + child.on('exit', (exitCode) => { + expect(exitCode).to.equal(0) expect(result).to.equal('completed first\ncompleted second\nremoved\n') done() })