Skip to content

Conversation

kobenguyent
Copy link
Collaborator

Motivation/Description of the PR

  • Description of this PR, which problem it solves
  • Resolves #issueId (if applicable).

Applicable helpers:

  • Playwright
  • Puppeteer
  • WebDriver
  • REST
  • FileHelper
  • Appium
  • TestCafe

Applicable plugins:

  • allure
  • autoDelay
  • autoLogin
  • customLocator
  • pauseOnFail
  • coverage
  • retryFailedStep
  • screenshotOnFail
  • selenoid
  • stepByStepReport
  • stepTimeout
  • wdio
  • subtitles

Type of change

  • 🔥 Breaking changes
  • 🚀 New functionality
  • 🐛 Bug fix
  • 🧹 Chore
  • 📋 Documentation changes/updates
  • ♨️ Hot fix
  • 🔨 Markdown files fix - not related to source code
  • 💅 Polish code

Checklist:

  • Tests have been added
  • Documentation has been added (Run npm run docs)
  • Lint checking (Run npm run lint)
  • Local tests are passed (Run npm test)

@kobenguyent kobenguyent linked an issue Oct 1, 2025 that may be closed by this pull request
Copy link
Contributor

@Copilot Copilot AI left a 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.

@kobenguyent kobenguyent requested a review from Copilot October 1, 2025 09:31
Copy link
Contributor

@Copilot Copilot AI left a 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]>
@kobenguyent kobenguyent requested a review from Copilot October 1, 2025 09:32
Copy link
Contributor

@Copilot Copilot AI left a 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')

Copy link
Preview

Copilot AI Oct 1, 2025

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.

Suggested change
// 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
Copy link
Preview

Copilot AI Oct 1, 2025

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.

Suggested change
// 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.

@kobenguyent kobenguyent merged commit 5826298 into 3.x Oct 1, 2025
14 checks passed
@kobenguyent kobenguyent deleted the 5226-fix-maxlistenersexceededwarning branch October 1, 2025 09:53
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.

fix MaxListenersExceededWarning
2 participants