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

Calling custom command leads to error event listener > defaultMaxListeners error #3387

Closed
kretschmannj opened this issue Sep 15, 2022 · 0 comments · Fixed by #3416
Closed
Assignees
Labels

Comments

@kretschmannj
Copy link

kretschmannj commented Sep 15, 2022

Description of the bug/issue

Calling a custom command is incrementing the error event listener count eventually leading to an error indicating that the number of listeners exceeds the max limit (yes, I realize you can increase the defaultMaxListeners value but that is a workaround, not a solution).

Steps to reproduce

  1. Create logMsg.js in the custom_commands folder
  2. Create test.js in the tests folder
  3. Add console log to node_modules\nightwatch\lib\core\treenode.js ...
    commandResult
      .once('complete', result => {
        resolveFn(result);
      })
    **if (commandResult.listenerCount("error") > 0) console.log("commandResult error listener count: " + commandResult.listenerCount("error") + " [" + this.fullName + "]")**
    commandResult
      .once('error', (err, abortOnFailure) => {
        err.abortOnFailure = abortOnFailure || abortOnFailure === undefined;
        rejectFn(err);
      });
  1. Run tests.js (node nightwatch -e firefox tests/test.js)

Sample test

logMsg.js
exports.command = function () {
	this.pause(1) // function won't exit without this
}

test.js
module.exports = {
	"Test" : browser => {
		browser.logMsg().pause(1000)
		browser.logMsg().pause(1000)
		browser.logMsg().pause(1000)
		browser.logMsg().pause(1000)
	}
}

Command to run

node nightwatch -e firefox tests/test.js

Verbose Output

Starting test  [sessionId: 7f0618e7-3ec3-47db-9b7e-3e95c10e99f0]

  Running Test:
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
commandResult error listener count: 1 [logMsg]
commandResult error listener count: 2 [logMsg]
commandResult error listener count: 3 [logMsg]
commandResult error listener count: 4 [logMsg]
No assertions ran.


Completed test

Nightwatch Configuration

No response

Nightwatch.js Version

2.3.0

Node Version

14.17.1

Browser

No response

Operating System

Windows 10

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants