Skip to content
Closed
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
159 changes: 159 additions & 0 deletions test/issue-pool-keep-alive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
'use strict'

const { tspl } = require('@matteo.collina/tspl')
const { test, after } = require('node:test')
const { Pool, Client } = require('..')
const { createServer } = require('node:http')

// Client passes okay
test('client respects keep-alive', async (t) => {
t = tspl(t, { plan: 1 })
const server = createServer({ joinDuplicateHeaders: true, keepAlive: true }, (req, res) => {
// Server always responds with a 20s keep-alive header
res.writeHead(200, { 'Content-Type': 'text/plain', Connection: 'keep-alive', 'Keep-Alive': 'timeout=20' })
res.end('foo')
})

let connections = 0
server.on('connection', () => {
connections++
})
after(() => server.close())
const expectedConnections = 1
const keepAliveTimeout = 20 * 1000 // 20 seconds
server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`, { keepAliveTimeout, keepAliveMaxTimeout: keepAliveTimeout * 2 })
after(() => client.close())

client.request({ path: '/', method: 'GET' }, (err, res) => {
if (err) {
t.fail(err)
return
}
res.body.on('end', () => {
client.request({ path: '/', method: 'GET' }, (err, res) => {
if (err) {
t.fail(err)
return
}
setTimeout(() => {
res.body.on('end', () => {
t.strictEqual(connections, expectedConnections, 'Client connections should have been reused')
}).resume()
}, keepAliveTimeout / 2)
})
}).resume()
})
})
await t.completed
})

test.only('Pool respects keep-alive', async t => {

Check notice on line 51 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (22, ubuntu-latest) / Test with Node.js 22 on ubuntu-latest

'only' and 'runOnly' require the --test-only command-line option.

Check notice on line 51 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (24, ubuntu-latest) / Test with Node.js 24 on ubuntu-latest

'only' and 'runOnly' require the --test-only command-line option.

Check notice on line 51 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (20, ubuntu-latest) / Test with Node.js 20 on ubuntu-latest

'only' and 'runOnly' require the --test-only command-line option.

Check notice on line 51 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (24, macos-latest) / Test with Node.js 24 on macos-latest

'only' and 'runOnly' require the --test-only command-line option.

Check notice on line 51 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (22, macos-latest) / Test with Node.js 22 on macos-latest

'only' and 'runOnly' require the --test-only command-line option.

Check notice on line 51 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (20, macos-latest) / Test with Node.js 20 on macos-latest

'only' and 'runOnly' require the --test-only command-line option.

Check notice on line 51 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / Test with Node.js 20 compiled --without-intl

'only' and 'runOnly' require the --test-only command-line option.

Check notice on line 51 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / Test with Node.js 22 compiled --without-intl

'only' and 'runOnly' require the --test-only command-line option.

Check notice on line 51 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / Test with Node.js 24 compiled --without-intl

'only' and 'runOnly' require the --test-only command-line option.
t = tspl(t, { plan: 1 })

const server = createServer({ joinDuplicateHeaders: true, keepAlive: true }, (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain', Connection: 'keep-alive', 'Keep-Alive': 'timeout=2' })
res.end('foo')
})
let connections = 0
server.on('connection', () => {
connections++
})
after(() => server.close())
const expectedConnections = 1
const keepAliveTimeout = 2 * 1000 // 2 seconds
server.listen(0, () => {
const pool = new Pool(`http://localhost:${server.address().port}`, { connections: expectedConnections, keepAliveTimeout, keepAliveMaxTimeout: keepAliveTimeout * 2 })
pool.on('connectionError', (err) => {
console.error('Connection error')
console.error(err)
})
after(() => pool.close())
pool.request({ path: '/', method: 'GET' }, (err, res) => {
if (err) {
t.fail(err)
return
}
res.body.on('end', () => {
setTimeout(() => {
pool.request({ path: '/', method: 'GET' }, (err, res) => {
if (err) {
t.fail(err)
return
}
res.body.on('end', () => {
t.strictEqual(connections, expectedConnections, 'Pool connections should have been reused between batches')

Check failure on line 85 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (22, ubuntu-latest) / Test with Node.js 22 on ubuntu-latest

Pool respects keep-alive

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:518:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/home/runner/work/undici/undici/test/issue-pool-keep-alive.js:85:17) at BodyReadable.emit (node:events:518:28) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 85 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (24, ubuntu-latest) / Test with Node.js 24 on ubuntu-latest

Pool respects keep-alive

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:507:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/home/runner/work/undici/undici/test/issue-pool-keep-alive.js:85:17) at BodyReadable.emit (node:events:507:28) at endReadableNT (node:internal/streams/readable:1701:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 85 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (20, ubuntu-latest) / Test with Node.js 20 on ubuntu-latest

Pool respects keep-alive

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:524:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/home/runner/work/undici/undici/test/issue-pool-keep-alive.js:85:17) at BodyReadable.emit (node:events:524:28) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 85 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (24, macos-latest) / Test with Node.js 24 on macos-latest

Pool respects keep-alive

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:507:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/Users/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/Users/runner/work/undici/undici/test/issue-pool-keep-alive.js:85:17) at BodyReadable.emit (node:events:507:28) at endReadableNT (node:internal/streams/readable:1701:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 85 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (22, macos-latest) / Test with Node.js 22 on macos-latest

Pool respects keep-alive

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:518:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/Users/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/Users/runner/work/undici/undici/test/issue-pool-keep-alive.js:85:17) at BodyReadable.emit (node:events:518:28) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 85 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (20, macos-latest) / Test with Node.js 20 on macos-latest

Pool respects keep-alive

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:524:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/Users/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/Users/runner/work/undici/undici/test/issue-pool-keep-alive.js:85:17) at BodyReadable.emit (node:events:524:28) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 85 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / Test with Node.js 20 compiled --without-intl

Pool respects keep-alive

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:524:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/home/runner/work/undici/undici/test/issue-pool-keep-alive.js:85:17) at BodyReadable.emit (node:events:524:28) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 85 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / Test with Node.js 22 compiled --without-intl

Pool respects keep-alive

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:518:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/home/runner/work/undici/undici/test/issue-pool-keep-alive.js:85:17) at BodyReadable.emit (node:events:518:28) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 85 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / Test with Node.js 24 compiled --without-intl

Pool respects keep-alive

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:507:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/home/runner/work/undici/undici/test/issue-pool-keep-alive.js:85:17) at BodyReadable.emit (node:events:507:28) at endReadableNT (node:internal/streams/readable:1701:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }
}).resume()
})
}, keepAliveTimeout / 2)
}).resume()
})
})
await t.completed
})

// Pool fails
test('pool respects keep-alive batched requests', async t => {
t = tspl(t, { plan: 1 })

const server = createServer({ joinDuplicateHeaders: true, keepAlive: true }, (req, res) => {
// Server always responds with a 20s keep-alive header
res.writeHead(200, { 'Content-Type': 'text/plain', Connection: 'keep-alive', 'Keep-Alive': 'timeout=20' })
res.end('foo')
})
let connections = 0
server.on('connection', () => {
connections++
})
after(() => server.close())
// Can also use `10`
const expectedConnections = 1
const keepAliveTimeout = 20 * 1000 // 20 seconds
server.listen(0, () => {
// Pool is set to keep connections alive for 20 seconds too
const pool = new Pool(`http://localhost:${server.address().port}`, { connections: expectedConnections, keepAliveTimeout, keepAliveMaxTimeout: keepAliveTimeout * 2 })
pool.on('connectionError', (err) => {
console.error('Connection error')
console.error(err)
})
after(() => pool.close())

// Can also use `20`
const batchSize = 2
let batch1Completed = 0
for (let i = 0; i < batchSize; i++) {
pool.request({ path: '/', method: 'GET' }, (err, res) => {
if (err) {
t.fail(err)
return
}
res.body.on('end', () => {
batch1Completed++
if (batch1Completed === batchSize) {
// Once the first batch is done, wait half of the keep-alive timeout
setTimeout(() => {
// And execute another batch of requests
let batch2Completed = 0
for (let j = 0; j < batchSize; j++) {
pool.request({ path: '/', method: 'GET' }, (err, res) => {
if (err) {
t.fail(err)
return
}
res.body.on('end', () => {
batch2Completed++
if (batch2Completed === batchSize) {
t.strictEqual(connections, expectedConnections, 'Pool connections should have been reused between batches')

Check failure on line 146 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (22, ubuntu-latest) / Test with Node.js 22 on ubuntu-latest

pool respects keep-alive batched requests

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:518:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/home/runner/work/undici/undici/test/issue-pool-keep-alive.js:146:25) at BodyReadable.emit (node:events:518:28) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 146 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (24, ubuntu-latest) / Test with Node.js 24 on ubuntu-latest

pool respects keep-alive batched requests

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:507:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/home/runner/work/undici/undici/test/issue-pool-keep-alive.js:146:25) at BodyReadable.emit (node:events:507:28) at endReadableNT (node:internal/streams/readable:1701:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 146 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (20, ubuntu-latest) / Test with Node.js 20 on ubuntu-latest

pool respects keep-alive batched requests

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:524:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/home/runner/work/undici/undici/test/issue-pool-keep-alive.js:146:25) at BodyReadable.emit (node:events:524:28) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 146 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (24, macos-latest) / Test with Node.js 24 on macos-latest

pool respects keep-alive batched requests

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:507:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/Users/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/Users/runner/work/undici/undici/test/issue-pool-keep-alive.js:146:25) at BodyReadable.emit (node:events:507:28) at endReadableNT (node:internal/streams/readable:1701:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 146 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (22, macos-latest) / Test with Node.js 22 on macos-latest

pool respects keep-alive batched requests

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:518:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/Users/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/Users/runner/work/undici/undici/test/issue-pool-keep-alive.js:146:25) at BodyReadable.emit (node:events:518:28) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 146 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / test (20, macos-latest) / Test with Node.js 20 on macos-latest

pool respects keep-alive batched requests

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:524:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/Users/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/Users/runner/work/undici/undici/test/issue-pool-keep-alive.js:146:25) at BodyReadable.emit (node:events:524:28) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 146 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / Test with Node.js 20 compiled --without-intl

pool respects keep-alive batched requests

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:524:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/home/runner/work/undici/undici/test/issue-pool-keep-alive.js:146:25) at BodyReadable.emit (node:events:524:28) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 146 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / Test with Node.js 22 compiled --without-intl

pool respects keep-alive batched requests

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:518:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/home/runner/work/undici/undici/test/issue-pool-keep-alive.js:146:25) at BodyReadable.emit (node:events:518:28) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }

Check failure on line 146 in test/issue-pool-keep-alive.js

View workflow job for this annotation

GitHub Actions / Test with Node.js 24 compiled --without-intl

pool respects keep-alive batched requests

Error [ERR_TEST_FAILURE]: Pool connections should have been reused between batches 2 !== 1 at process.emit (node:events:507:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: Pool connections should have been reused between batches 2 !== 1 at res.<computed> [as strictEqual] (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:58:35) at BodyReadable.<anonymous> (/home/runner/work/undici/undici/test/issue-pool-keep-alive.js:146:25) at BodyReadable.emit (node:events:507:28) at endReadableNT (node:internal/streams/readable:1701:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 2, expected: 1, operator: 'strictEqual' } }
}
}).resume()
})
}
}, keepAliveTimeout / 2)
}
}).resume()
})
}
})

await t.completed
})
Loading