Skip to content

doc: emphasize "timeout" and "request.setTimeout()" difference

This change brings emphasis on the difference between these two ways of setting a socket timeout on an HTTP request:

http.request(url, { timeout: n })
http.request(url).setTimeout(n)

The two are completely different, and the current state of the docs failed to highlight that difference when I was debugging an issue.

  • The timeout option on http.request() is forwarded to the http.Agent and applies timeout immediately when the socket is created.
  • The request.setTimeout() method is not forwarded to the http.Agent, and applies timeout after the socket has connected.

Merge request reports

Loading