Skip to content

Commit

Permalink
Fix Memory Leak in AsyncHttpCall affecting auth.listUsers (#2236)
Browse files Browse the repository at this point in the history
fixes 2235
The socket code was only introduced to fix a bug in NodeJS 12 (db8be26) and since then has even needed a patch (1a34bc4). However the code does not seem necessary at all anymore.
Removing this code resolved the described memory leak.

Co-authored-by: Lahiru Maramba <llahiru@gmail.com>
  • Loading branch information
adrianjost and lahirumaramba committed Jul 10, 2023
1 parent b9eaae6 commit c21de1e
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/utils/api-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,14 +504,6 @@ class AsyncHttpCall {
if (timeout) {
// Listen to timeouts and throw an error.
req.setTimeout(timeout, timeoutCallback);
req.on('socket', (socket) => {
socket.setMaxListeners(socket.getMaxListeners() + 1);
socket.setTimeout(timeout, timeoutCallback);
socket.on('end', () => {
socket.setTimeout(0);
socket.setMaxListeners(Math.max(socket.getMaxListeners() - 1, 0));
});
});
}

// Send the request
Expand Down

0 comments on commit c21de1e

Please sign in to comment.