From e5560f28caf02bcd9351309bc7f867898572b213 Mon Sep 17 00:00:00 2001 From: Daniel <3473356+D4N14L@users.noreply.github.com> Date: Thu, 9 Jan 2025 13:57:26 -0800 Subject: [PATCH] [rush-lib] Fix issue with `MaxListenersExceeded` while using the HTTP build cache plugin (#5073) * Remove the socket error handler for WebClient * Rush change * Remove unused import --------- Co-authored-by: Daniel --- ...nade-RemoveSocketErrorHandler_2025-01-09-20-04.json | 10 ++++++++++ libraries/rush-lib/src/utilities/WebClient.ts | 6 ------ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 common/changes/@microsoft/rush/user-danade-RemoveSocketErrorHandler_2025-01-09-20-04.json diff --git a/common/changes/@microsoft/rush/user-danade-RemoveSocketErrorHandler_2025-01-09-20-04.json b/common/changes/@microsoft/rush/user-danade-RemoveSocketErrorHandler_2025-01-09-20-04.json new file mode 100644 index 00000000000..ac2c338d63e --- /dev/null +++ b/common/changes/@microsoft/rush/user-danade-RemoveSocketErrorHandler_2025-01-09-20-04.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Fix an issue where MaxListenersExceeded would get thrown when using the HTTP build cache plugin", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/libraries/rush-lib/src/utilities/WebClient.ts b/libraries/rush-lib/src/utilities/WebClient.ts index 45948ecbb57..6cee2f138cd 100644 --- a/libraries/rush-lib/src/utilities/WebClient.ts +++ b/libraries/rush-lib/src/utilities/WebClient.ts @@ -6,7 +6,6 @@ import * as process from 'process'; import type * as http from 'http'; import { request as httpRequest, type IncomingMessage } from 'node:http'; import { request as httpsRequest, type RequestOptions } from 'node:https'; -import type { Socket } from 'node:net'; import { Import, LegacyAdapters } from '@rushstack/node-core-library'; const createHttpsProxyAgent: typeof import('https-proxy-agent') = Import.lazy('https-proxy-agent', require); @@ -199,11 +198,6 @@ const makeRequestAsync: FetchFn = async ( resolve(result); }); }) - .on('socket', (socket: Socket) => { - socket.on('error', (error: Error) => { - reject(error); - }); - }) .on('error', (error: Error) => { reject(error); })