Skip to content

Commit 0a8f762

Browse files
author
Frédérick Loranger
committed
Prevent memory leaks when calling _request()
Whenever the _request() function gets called, if the request callback gets properly called (i.e. it is executed before timeout), the callback function is never removed from the _requests object. We need to remove the callbacks when they are executed, otherwise they will keep accumulating in memory indefinitely.
1 parent 733f664 commit 0a8f762

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/client.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@
416416
// Add request callback
417417
client._requests[req.id] = function(err, result) {
418418
clearTimeout(timeout);
419+
delete client._requests[req.id];
419420
if (err) return reject(new Error(err));
420421
resolve(result);
421422
};

0 commit comments

Comments
 (0)