-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Closed
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.
Description
- Version: v11.6.0
- Platform: all
- Subsystem: http, net
This was originally discovered by @szmarczak and reported as sindresorhus/got#690.
Unless we're mistaken, setTimeout(0) on an HTTP request (and then socket) can lead to a timeout listener not being removed. This is problematic because combined with a keepalive agent, it can lead to a memory leak.
This Gist by Szymon illustrates the issue. For convenience, I'm also quoting his inline explanation here:
request.setTimeoutcallslistenSocketTimeout:
https://github.com/nodejs/node/blob/v11.6.0/lib/_http_client.js#L736listenSocketTimeoutcreates a proxy (timeoutevent)Socket->ClientRequest: https://github.com/nodejs/node/blob/v11.6.0/lib/_http_client.js#L673- The proxy event is released on the response
endevent:
https://github.com/nodejs/node/blob/v11.6.0/lib/_http_client.js#L682In this case this never happens, because we set the timeout on that particular event. The correct behaviour would be to prevent calling
listenSocketTimeoutifmsecsis 0.
szmarczak, sindresorhus, dima-takoy-zz and pito-svk
Metadata
Metadata
Assignees
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.