node-js-libs / curlrequest

A cURL wrapper
MIT License
184 stars 44 forks source link

Do not setTimeout if in pretend mode #66

Open afharo opened 5 years ago

afharo commented 5 years ago

When on pretend mode, it is not clearing the setTimeouts. This change will try to avoid creating them if in pretend mode.

afharo commented 5 years ago

Hello! Can anyone review this PR? It is causing an important memory leak because it's allocating timeouts and never clearing them when using them in pretend mode. I use this to help me with the logging of my API requests, but using other libraries to perform the actual request. So the only use I make of this library is pretend only. For every single call, it's allocating a timeout that won't be cleared until it fires off. Also calling the callback twice (once for the successful logging + a second time when the timeout fires off), not allowing the Garbage Collector to clear my callback code either.