-
Notifications
You must be signed in to change notification settings - Fork 551
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
headersTimeout on Agent appears to be broken since 6.20.0 #3798
Comments
Du you have a full repro? |
|
The behaviour is indeed changed, I couldn't reproduce it your code in isolation; but I was able to figure out that this might has to be something with the work done for the fast timers. As, if e.g. For instance, my guess is that maybe mocha does something with timers that messes the fast timers implementation and causes undici to drift some the expected behaviour. import { createServer } from 'node:http'
import { once } from 'node:events'
import { Agent, fetch } from './index.js' // main & v6.x behaves the same
const app = createServer((req, res) => {
setTimeout(() => {
res.writeHead(200, { 'Content-Type': 'text/plain' })
res.end('hello world')
}, 10) // Change to 500 or 1000 to cause a UND_ERR_HEADERS_TIMEOUT
})
app.listen(0)
await once(app, 'listening')
const dispatcher = new Agent({
connectTimeout: 1,
bodyTimeout: 1,
headersTimeout: 1
})
const result = await fetch(`http://127.0.0.1:${app.address().port}/delayed`, {
redirect: 'manual',
headers: { accept: 'text/plain' },
method: 'GET',
keepalive: true,
dispatcher
})
console.log(result.status, await result?.text())
|
Bug Description
Using
fetch
with anundici
agent with configuration such asnew Agent({ headersTimeout: 1})
on6.19.8
would correctly throw aUND_ERR_HEADERS_TIMEOUT
error whereas on6.20.0
and6.20.1
the request just hangs.This was caught by some tests we have around our http client that ensures timeouts work, and they started failing after the
undici
bump.Reproducible By
As above really.
Expected Behavior
UND_ERR_HEADERS_TIMEOUT
to throw on a headers timeout.Logs & Screenshots
Environment
node v22.5.1
undici v6.20.x
Additional context
The text was updated successfully, but these errors were encountered: