Conversation
There was a problem hiding this comment.
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.
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 <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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.
| @@ -2,13 +2,22 @@ const debug = require('debug')('codeceptjs:event') | |||
| const events = require('events') | |||
| const { error } = require('./output') | |||
|
|
|||
There was a problem hiding this comment.
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. |
| 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.
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. |
Motivation/Description of the PR
Applicable helpers:
Applicable plugins:
Type of change
Checklist:
npm run docs)npm run lint)npm test)