From e426e6d744c3af237c312666ee644a6369cf10d7 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 23 Jul 2026 14:44:38 +0200 Subject: [PATCH] Add stack trace logging for MaxListenersExceededWarning --- apps/api/src/main.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 77d571ea0b..b30a20323e 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -26,6 +26,15 @@ import { AppModule } from './app/app.module'; import { environment } from './environments/environment'; const logger = new Logger('Bootstrap'); +const processWarningLogger = new Logger('ProcessWarning'); + +process.on('warning', ({ name, stack }) => { + if (name === 'MaxListenersExceededWarning') { + // Log the stack trace of MaxListenersExceededWarning occurrences to identify + // the event emitter and the call site which registers the listeners + processWarningLogger.warn(stack); + } +}); async function bootstrap() { // Respect HTTP_PROXY / HTTPS_PROXY / NO_PROXY for outbound HTTP requests