From fab16d09799787693e78ad1fbd4f0917c2c86299 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 23 Jul 2026 17:45:58 +0200 Subject: [PATCH] Task/add stack trace logging for MaxListenersExceededWarning (#7400) * Add stack trace logging for MaxListenersExceededWarning * Update changelog --- CHANGELOG.md | 4 ++++ apps/api/src/main.ts | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f936dd472..3b0b0a418 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added the stack trace logging for `MaxListenersExceededWarning` occurrences + ### Changed - Refactored the deprecated animation providers (`provideAnimations()` and `provideNoopAnimations()`) diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 77d571ea0..b30a20323 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