Skip to content

Commit 099d5e6

Browse files
committed
fix: update issue-5137 test for headers/body timeout split (use h2c, set headersTimeout, expect HeadersTimeoutError)
1 parent a9e6a8f commit 099d5e6

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

test/issue-5137.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
const { tspl } = require('@matteo.collina/tspl')
44
const { test, after } = require('node:test')
5-
const { createSecureServer } = require('node:http2')
5+
const { createServer } = require('node:http2')
66
const { once } = require('node:events')
77

8-
const pem = require('@metcoder95/https-pem')
9-
108
const { RetryAgent, Client } = require('..')
119

1210
// Regression test for https://github.com/nodejs/undici/issues/5137
@@ -19,7 +17,7 @@ const { RetryAgent, Client } = require('..')
1917
test('RetryAgent rejects after exhausting retries on HTTP/2 stream timeout', async t => {
2018
t = tspl(t, { plan: 2 })
2119

22-
const server = createSecureServer(await pem.generate({ opts: { keySize: 2048 } }))
20+
const server = createServer()
2321

2422
let streamCount = 0
2523
let resolveStreamCount
@@ -39,10 +37,11 @@ test('RetryAgent rejects after exhausting retries on HTTP/2 stream timeout', asy
3937
await once(server.listen(0), 'listening')
4038

4139
const client = new RetryAgent(
42-
new Client(`https://localhost:${server.address().port}`, {
43-
connect: { rejectUnauthorized: false },
40+
new Client(`http://localhost:${server.address().port}`, {
4441
allowH2: true,
45-
bodyTimeout: 50
42+
useH2c: true,
43+
bodyTimeout: 50,
44+
headersTimeout: 50
4645
}),
4746
{
4847
maxRetries: 3,
@@ -61,8 +60,8 @@ test('RetryAgent rejects after exhausting retries on HTTP/2 stream timeout', asy
6160

6261
// The request itself should reject after exhausting retries
6362
await t.rejects(client.request({ path: '/', method: 'GET' }), {
64-
code: 'UND_ERR_INFO',
65-
message: /stream timeout/
63+
code: 'UND_ERR_HEADERS_TIMEOUT',
64+
message: /headers timeout/
6665
})
6766

6867
await streamCountReached

0 commit comments

Comments
 (0)