Response timeout does not work as expected
See original GitHub issueThe following code doesn’t work as expected (no timeout error is fired):
client.get('/stop-writing-body-halfway', {
timeout: 100,
})
After a few minutes, a response is resolved despite Content-Length
not having been reached and the server not explicitly closing the connection. Edit: never mind the connection is probably closed after 2 mins because of https://nodejs.org/api/http.html#http_server_timeout
My server never closes the connection and stops writing the body half way:
const stopWritingBodyHalfway = (msg, res) => {
res.setHeader('Content-Length', 500)
const body = Buffer.alloc(250, 'a')
res.write(body)
}
Is the timeout only for the request, not for the response?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:17
- Comments:20 (2 by maintainers)
Top Results From Across the Web
Why Connect Timeout and Response Timeout not working in ...
I notice that Connect Timeout and Response Timeout are not working as expected. In the HTTP Request, I've specified Connect Timeout to be...
Read more >408 Request Timeout - HTTP - MDN Web Docs
The HyperText Transfer Protocol (HTTP) 408 Request Timeout response status code means that the server would like to shut down this unused ...
Read more >expect -timeout vs. "set timeout" in expect: Different behavior
The problem is explained fully in the Stack Overflow post. Why doesn't this expect handle timeout or eof. In short, the -timeout flag...
Read more >Troubleshoot your Application Load Balancers
Troubleshoot issues that you might encounter with your Application Load ... that the target page is not responding before the health check timeout...
Read more >FIX: The Timeout parameter for the IcmpSendEcho function ...
File name File size Date Time Path
Ipv4.lib 2,473,026 12‑Mar‑2012 17:49 Public\Common\Oak\Lib\Armv5\Checked
Ipv4.lib 2,550,392 12‑Mar‑2012 17:48 Public\Common\Oak\Lib\Armv5\Debug
Ipv4.lib 2,370,616 12‑Mar‑2012 17:48 Public\Common\Oak\Lib\Armv5\Retail
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In case it’s useful to anyone I’ve been patching the behaviour of
timeout
by using an interceptor. It uses a cancel token to cancel the request aftertimeout
has elapsed.@olalonde Yes, exactly. At the moment, the current timeout is cleared before the response body has been completely received:
https://github.com/mzabriskie/axios/blob/master/lib/adapters/http.js#L116
The timeout gets cleared before the body stream is processed.
Instead the timeout could be be cleared later (when the body has been completely received).