Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run server.closeAllConnections() before server.close() #666

Merged
merged 1 commit into from
May 24, 2024

Conversation

andygout
Copy link
Owner

This PR addresses an issue that was encountered on another Node.js app with a Neo4j database in which after a change was made to the code which triggered a Nodemon restart of the server, it would be impossible to close the server using ctrl + c and would require that the entire CLI shell was closed.

Upon the sixth attempt at ctrl + c, the following message would appear:

(node:26548) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [Server]. Use emitter.setMaxListeners() to increase limit
(Use node --trace-warnings ... to show where the warning was created)

Each attempt of ctrl + c would call server.close() twice (but not invoke the callback), so the sixth attempt would reach the 11th call, indicating that each call would add a close listener.

I'm not sure of the exact cause, but the below references helped lead me to a solution.

References:

@andygout andygout force-pushed the run-server-close-all-connections-before-server-close branch from 296dbf5 to 336d526 Compare May 23, 2024 21:00
@andygout andygout merged commit 956783e into main May 24, 2024
1 check passed
@andygout andygout deleted the run-server-close-all-connections-before-server-close branch May 24, 2024 12:02
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.

1 participant