Is there a default timeout in Node.js for http.request?

You want to set the server.timeout property (it defaults to 120,000, as you've found).


Update: Node.js 13 has removed the default timeout:

  • https://nodejs.org/api/http.html#servertimeout
  • https://github.com/nodejs/node/pull/27558

I was also interested in this. By reading the code, Node.js uses Socket under the hood of http request (naturally). (The source link below is referring v8.8.0 at the point when I'm writing this)

https://github.com/nodejs/node/blob/master/lib/_http_outgoing.js

And Socket does not have the timeout by default by this document

https://nodejs.org/dist/latest-v6.x/docs/api/net.html#net_socket_settimeout_timeout_callback

And the source tells the same.

https://github.com/nodejs/node/blob/master/lib/net.js

Tags:

Node.Js