Skip to content
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
16 changes: 14 additions & 2 deletions test/issue-5137.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ test('RetryAgent rejects after exhausting retries on HTTP/2 stream timeout', asy
t = tspl(t, { plan: 2 })

const server = createServer()
// The client intentionally times out and resets h2c streams in this test.
// Swallow the expected teardown errors so node:test does not report them
// as asynchronous activity after the assertions complete.
server.on('error', () => {})
server.on('session', session => {
session.on('error', () => {})
session.socket?.on('error', () => {})
})

let streamCount = 0
let resolveStreamCount
Expand All @@ -26,14 +34,17 @@ test('RetryAgent rejects after exhausting retries on HTTP/2 stream timeout', asy
})

server.on('stream', (stream) => {
// Client-side stream timeouts reset these h2c streams. On some
// platforms the expected reset can surface after the assertions finish.
stream.on('error', () => {})
streamCount++
if (streamCount === 3) {
resolveStreamCount()
}
// Never respond — simulates a perpetual stream timeout
})

after(() => server.close())
after(() => new Promise(resolve => server.close(resolve)))
await once(server.listen(0), 'listening')

const client = new RetryAgent(
Expand All @@ -56,7 +67,7 @@ test('RetryAgent rejects after exhausting retries on HTTP/2 stream timeout', asy
}
}
)
after(() => client.close())
after(() => client.close().catch(() => {}))

// The request itself should reject after exhausting retries
await t.rejects(client.request({ path: '/', method: 'GET' }), {
Expand All @@ -70,4 +81,5 @@ test('RetryAgent rejects after exhausting retries on HTTP/2 stream timeout', asy
t.equal(streamCount, 3, 'server should have received all 3 request attempts')

await t.completed
await client.close()
})
Loading