Skip to content

Commit f1d75a4

Browse files
committed
increase timeout for redirect test
Signed-off-by: Matteo Collina <[email protected]>
1 parent 2d31ed6 commit f1d75a4

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

.taprc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ jsx: false
33
flow: false
44
coverage: false
55
expose-gc: true
6-
timeout: 60
6+
timeout: 120
77
check-coverage: false

test/redirect-request.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,16 @@ for (const factory of [
354354
t.test('should follow redirections when going cross origin', async t => {
355355
const [server1, server2, server3] = await startRedirectingChainServers(t)
356356

357+
const agent = new Agent({
358+
keepAliveTimeout: 1000,
359+
keepAliveMaxTimeout: 1000
360+
})
361+
t.teardown(agent.close.bind(agent))
362+
357363
const { statusCode, headers, body: bodyStream, context: { history } } = await undici.request(`http://${server1}`, {
358364
method: 'POST',
359-
maxRedirections: 10
365+
maxRedirections: 10,
366+
dispatcher: agent
360367
})
361368

362369
const body = await bodyStream.text()
@@ -381,6 +388,7 @@ t.test('should handle errors (callback)', t => {
381388
keepAliveTimeout: 1000,
382389
keepAliveMaxTimeout: 1000
383390
})
391+
t.teardown(agent.close.bind(agent))
384392

385393
undici.request(
386394
'http://localhost:0',
@@ -399,6 +407,7 @@ t.test('should handle errors (promise)', async t => {
399407
keepAliveTimeout: 1000,
400408
keepAliveMaxTimeout: 1000
401409
})
410+
t.teardown(agent.close.bind(agent))
402411
try {
403412
await undici.request('http://localhost:0', { maxRedirections: 10, dispatcher: agent })
404413
t.fail('Did not throw')
@@ -412,6 +421,7 @@ t.test('removes authorization header on third party origin', async t => {
412421
keepAliveTimeout: 1000,
413422
keepAliveMaxTimeout: 1000
414423
})
424+
t.teardown(agent.close.bind(agent))
415425
const [server1] = await startRedirectingWithAuthorization(t, 'secret')
416426
const { body: bodyStream } = await undici.request(`http://${server1}`, {
417427
maxRedirections: 10,
@@ -431,6 +441,7 @@ t.test('removes cookie header on third party origin', async t => {
431441
keepAliveTimeout: 1000,
432442
keepAliveMaxTimeout: 1000
433443
})
444+
t.teardown(agent.close.bind(agent))
434445
const [server1] = await startRedirectingWithCookie(t, 'a=b')
435446
const { body: bodyStream } = await undici.request(`http://${server1}`, {
436447
maxRedirections: 10,

test/utils/redirecting-servers.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ function close (server) {
99
return new Promise(resolve => {
1010
if (isNode20) {
1111
server.closeAllConnections()
12+
server.close(function () {
13+
resolve()
14+
})
1215
}
13-
server.close(function () {
14-
resolve()
15-
})
16+
server.close()
17+
server.unref()
18+
resolve()
1619
})
1720
}
1821
}

0 commit comments

Comments
 (0)