[🐛 Bug]: MaxListenersExceededWarning using --parallel
What happened?
Running tests in parallel throws a Node MaxListenersExceededWarning, which you can see in the attached log output.
This seems to be the same as #6812 which was marked as stale due to lack of update.
The same test suite runs fine when not being used in parallel.
How can we reproduce the issue?
https://github.com/SeleniumHQ/selenium/issues/6812#issuecomment-451555700
I'm unable to provide the specific test suite I'm using as it's a closed system.
However the above link claims to have replicated the issue to allow diagnosis.
Relevant log output
(node:8308) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit
at _addListener (node:events:601:17)
at process.addListener (node:events:623:10)
at process.once (node:events:667:8)
at exec (D:\****\node_modules\selenium-webdriver\io\exec.js:135:11)
at D:\****\node_modules\selenium-webdriver\remote\index.js:213:29
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Executor.execute (D:\****\node_modules\selenium-webdriver\lib\http.js:505:16)
Operating System
Windows 10 & 11
Selenium version
JavaScript 4.3.1
What are the browser(s) and version(s) where you see this issue?
Firefox 102.0.1
What are the browser driver(s) and version(s) where you see this issue?
GeckoDriver 0.31.0
Are you using Selenium Grid?
No response
@lukesrw, thank you for creating this issue. We will troubleshoot it as soon as we can.
Info for maintainers
Triage this issue by using labels.
If information is missing, add a helpful comment and then I-issue-template label.
If the issue is a question, add the I-question label.
If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable G-* label, and it will provide the correct link and auto-close the
issue.
After troubleshooting the issue, please add the R-awaiting answer label.
Thank you!
I'm working on this issue.
I was working on this issue and reproduced it using the code mentioned at https://github.com/SeleniumHQ/selenium/issues/6812#issuecomment-451555700. On talking with @harsha509 we noticed that the issue was due to user not handling errors/failures correctly that blocks the driver instance.
For example,
in tests.zip, await driver.manage().timeouts().implicitlyWait(1000); is not the right way of declaring implicit wait. It should be await driver.manage().setTimeouts( { implicit: 10000 } );
If you can provide us with another code to reproduce the issue, it will be helpful.
I looked further in this issue and this is what my findings are so far.
I'm using the latest version of Selenium JS [4.4.0]
1) Every suite file under test/tests/... (i.e. from suite1.js to suite9.js) has an import statement
import { after, before, describe, it } from 'selenium-webdriver/testing';
This is not the correct way to use assertions. So I removed that line.
2) In file utils.js, there is an outdated line of code
await driver.manage().timeouts().implicitlyWait(1000);
I replaced it with the correct approach,
await driver.manage().setTimeouts( { implicit: 10000 } );
Please have a look at https://github.com/SeleniumHQ/selenium/blob/trunk/javascript/node/selenium-webdriver/test/lib/webdriver_test.js#L1651-L1730 for further overview of the setTimeouts() function.
Running the test suite now gives no MaxListeners warnings.
CONCLUSION:
- I recommend upgrading to Selenium 4.4.0.
- Make sure your code is correct and comaptible.
- Meanwhile I will write a documentation for setTimeouts() soon.
This issue can be closed. CC : @harsha509
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.