Skip to content

fix: prevent memory leak from process event listeners - #329

Merged
omegascorp merged 1 commit into
modelence:mainfrom
aadityakumarsah:fix/process-listeners-leak
Aug 28, 2026
Merged

fix: prevent memory leak from process event listeners#329
omegascorp merged 1 commit into
modelence:mainfrom
aadityakumarsah:fix/process-listeners-leak

Conversation

@aadityakumarsah

@aadityakumarsah aadityakumarsah commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

This PR fixes a MaxListenersExceededWarning caused by repeatedly registering process.on listeners in startServer across tests. It uses a module-level variable to ensure they are added only once.


Note

Low Risk
Small control-flow change around existing logging handlers; no new behavior on first boot and no auth or data-path impact.

Overview
Fixes listener accumulation when startServer runs multiple times in the same Node process (e.g. repeated test runs), which triggered MaxListenersExceededWarning.

Global unhandledRejection and uncaughtException handlers are now registered behind a module-level globalProcessListenersRegistered guard so they attach once; later startServer calls skip re-registration. Handler behavior is unchanged.

Reviewed by Cursor Bugbot for commit 9e6c1dd. Bugbot is set up for automated code reviews on this repo. Configure here.

@omegascorp
omegascorp self-requested a review August 27, 2026 12:35

@omegascorp omegascorp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@omegascorp
omegascorp merged commit 0f3135d into modelence:main Aug 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants