Superagent/Request Memory Leaks
Superagent/Request Memory Leaks
Superagent/Request Memory Leaks
The last several weeks Thomas Hunter and myself have spent some of our nights and weekends trying to track down memory leaks in an API we both work on.
We were seeing a distinct pattern, that when the API was put under a certain amount of load, that we would start slowly bleeding memory.
We’ve found three results:
-
Superagent, when put under a certain threshold of load and then connections timeout, can leak memory.
- The PR to fix this issue has been merged: https://github.com/visionmedia/superagent/pull/1084
-
Request, when put under a certain threshold of load and then connections timeout, can leak memory.
- The PR to fix this issue has been merged: https://github.com/request/request/pull/2420
-
Superagent, when not explicitly assigned a timeout parameter, can hold connections open and therefore leak memory
- The fix for this is to call req.timeout(YOUR_TIMEOUT_VALUE) to resolve.
The fixes for these issues are all in the latest versions of the libraries