Closed

Description
- Version: v12.13.1
- Platform: Linux lx9-981-10905 4.15.0-74-generic Proposal: Introduce CI builds to GitHub PR process #84-Ubuntu SMP Thu Dec 19 08:06:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
- Subsystem: Net.Socket
Documentation states that sockets do not have timeout on by default:
Sets the socket to timeout after timeout milliseconds of inactivity on the socket. By default net.Socket do not have a timeout.
And yet, HTTP requests time out after 2 minutes. According to links below, the time out would be hardcoded but I couldn't find proof of this.
https://stackoverflow.com/a/46157120
https://forum.nginx.org/read.php?2,214230,214239#msg-214239
Test case
server.js
const {createServer} = require('http');
createServer(async (req, res) => {
setTimeout(() => {
res.end();
}, 130000);
}).listen(1337);
$ node server.js
$ time curl -v localhost:1337
* Rebuilt URL to: localhost:1337/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 1337 (#0)
> GET / HTTP/1.1
> Host: localhost:1337
> User-Agent: curl/7.58.0
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
real 2m0.094s
user 0m0.009s
sys 0m0.018s
Workaround
server.js
const {createServer} = require('http');
createServer(async (req, res) => {
req.socket.setTimeout(0);
setTimeout(() => {
res.end();
}, 130000);
}).listen(1337);
$ node server.js
$ time curl -v localhost:1337
* Rebuilt URL to: localhost:1337/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 1337 (#0)
> GET / HTTP/1.1
> Host: localhost:1337
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Thu, 16 Jan 2020 10:35:48 GMT
< Connection: keep-alive
< Content-Length: 0
<
* Connection #0 to host localhost left intact
real 2m10.057s
user 0m0.027s
sys 0m0.018s
Metadata
Metadata
Assignees
Labels
No labels