Skip to content

test: Avoid silencing errors from idle timeout test’s child process #3419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/pg-pool/test/idle-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,30 @@ 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()
})
})

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()
})
Expand Down