From c21de1e94aaf74594a0b66644d5f7fb935a72134 Mon Sep 17 00:00:00 2001 From: Adrian Jost <22987140+adrianjost@users.noreply.github.com> Date: Mon, 10 Jul 2023 23:20:07 +0200 Subject: [PATCH] Fix Memory Leak in AsyncHttpCall affecting auth.listUsers (#2236) fixes 2235 The socket code was only introduced to fix a bug in NodeJS 12 (https://github.com/firebase/firebase-admin-node/commit/db8be2620a5c9cfc5b9824d9d2487ab9815f5baf) and since then has even needed a patch (https://github.com/firebase/firebase-admin-node/commit/1a34bc49373a5a34bb0efc006ea156d66168103c). However the code does not seem necessary at all anymore. Removing this code resolved the described memory leak. Co-authored-by: Lahiru Maramba --- src/utils/api-request.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/utils/api-request.ts b/src/utils/api-request.ts index 64fc49d87c..485ce3c8eb 100644 --- a/src/utils/api-request.ts +++ b/src/utils/api-request.ts @@ -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