-
-
Notifications
You must be signed in to change notification settings - Fork 750
fix: max listeners exceeded warning #5227
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses Node.js "max listeners exceeded" warnings by increasing the maximum number of event listeners allowed on both the custom event dispatcher and the global process object.
- Increased max listeners limit from 50 to 200 for the custom event dispatcher
- Added safeguard to increase process max listeners to 200 when the method is available
- Updated @types/node dependency to use caret range for better version flexibility
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
lib/event.js | Increases max listeners limits and adds process listener configuration with safety check |
package.json | Updates @types/node to use caret version range instead of exact version |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
const debug = require('debug')('codeceptjs:event') | ||
const events = require('events') | ||
const { error } = require('./output') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MAX_LISTENERS constant should include a comment explaining why 200 was chosen as the limit and under what conditions this value might need adjustment.
// The MAX_LISTENERS constant sets the maximum number of event listeners for the dispatcher and process. | |
// The value 200 was chosen to prevent EventEmitter memory leak warnings in large test suites, | |
// where many plugins, hooks, or reporters may register listeners. Adjust this value if you encounter | |
// warnings about possible memory leaks, or if your project requires more listeners due to additional | |
// extensions or integrations. |
Copilot uses AI. Check for mistakes.
dispatcher.setMaxListeners(50) | ||
dispatcher.setMaxListeners(MAX_LISTENERS) | ||
|
||
// Increase process max listeners to prevent warnings for beforeExit and other events |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conditional check and process configuration should include a comment explaining why it's necessary and what specific warnings it prevents.
// Increase process max listeners to prevent warnings for beforeExit and other events | |
// Set process max listeners to avoid "MaxListenersExceededWarning" when many listeners are attached to process events (e.g., "beforeExit"). | |
// This is necessary in large test suites to prevent Node.js from emitting warnings about possible memory leaks. |
Copilot uses AI. Check for mistakes.
Motivation/Description of the PR
Applicable helpers:
Applicable plugins:
Type of change
Checklist:
npm run docs
)npm run lint
)npm test
)