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

node:test beforeEach and afterEach generate MaxListenersExceededWarning #48475

Closed
lg250137 opened this issue Jun 16, 2023 · 3 comments · Fixed by #48915
Closed

node:test beforeEach and afterEach generate MaxListenersExceededWarning #48475

lg250137 opened this issue Jun 16, 2023 · 3 comments · Fixed by #48915

Comments

@lg250137
Copy link

lg250137 commented Jun 16, 2023

Version

v20.3.0

Platform

No response

Subsystem

node:test

What steps will reproduce the bug?

import {beforeEach, test} from "node:test"
beforeEach(() => {})
for (let i=1; i<=11; ++i) test(`${i}`, () => {})

Run tests with node --test

How often does it reproduce? Is there a required condition?

Consistently with 11 or more tests that share a beforeEach or afterEach hook. This does not occur if each test has its own after hook, e.g.: test(`${i}`, (t) => t.after(() => {}))

What is the expected behavior? Why is that the expected behavior?

No warning should be emitted when running the tests. It is reasonable to have more than 10 unit tests that share a beforeEach and/or afterEach hook, and explicitly using events.setMaxListeners() in the unit tests should not be necessary to avoid the warning.

What do you see instead?

$ node --trace-warnings --test
(node:11354) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit
    at [kNewListener] (node:internal/event_target:539:17)
    at [kNewListener] (node:internal/abort_controller:235:24)
    at EventTarget.addEventListener (node:internal/event_target:650:23)
    at eventTargetAgnosticAddListener (node:events:1024:13)
    at node:events:981:5
    at new Promise (<anonymous>)
    at once (node:events:964:10)
    at stopTest (node:internal/test_runner/test:78:12)
    at TestHook.run (node:internal/test_runner/test:547:27)
    at TestHook.run (node:internal/test_runner/test:748:18)

Additional information

No response

@rluvaton
Copy link
Member

rluvaton commented Jul 25, 2023

will fix it now

@Prateek462003
Copy link

Can i take a look at it ?

@rluvaton
Copy link
Member

Can i take a look at it ?

Sorry, missed that. maybe next time?

rluvaton added a commit to rluvaton/node that referenced this issue Jul 29, 2023
nodejs-github-bot pushed a commit that referenced this issue Jul 31, 2023
fix #48475

PR-URL: #48915
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
pluris pushed a commit to pluris/node that referenced this issue Aug 6, 2023
fix nodejs#48475

PR-URL: nodejs#48915
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
pluris pushed a commit to pluris/node that referenced this issue Aug 7, 2023
fix nodejs#48475

PR-URL: nodejs#48915
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Ceres6 pushed a commit to Ceres6/node that referenced this issue Aug 14, 2023
fix nodejs#48475

PR-URL: nodejs#48915
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Ceres6 pushed a commit to Ceres6/node that referenced this issue Aug 14, 2023
fix nodejs#48475

PR-URL: nodejs#48915
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
UlisesGascon pushed a commit to UlisesGascon/node that referenced this issue Aug 14, 2023
fix nodejs#48475

PR-URL: nodejs#48915
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
RafaelGSS pushed a commit that referenced this issue Aug 15, 2023
fix #48475

PR-URL: #48915
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
RafaelGSS pushed a commit to RafaelGSS/node that referenced this issue Aug 15, 2023
fix nodejs#48475

PR-URL: nodejs#48915
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
rluvaton added a commit to rluvaton/node that referenced this issue Aug 18, 2023
fix nodejs#48475

PR-URL: nodejs#48915
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
rluvaton added a commit to rluvaton/node that referenced this issue Sep 4, 2023
fix nodejs#48475

PR-URL: nodejs#48915
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
UlisesGascon pushed a commit that referenced this issue Sep 10, 2023
fix #48475

PR-URL: #48915
Backport-PR-URL: #49225
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
targos pushed a commit that referenced this issue Nov 27, 2023
fix #48475

PR-URL: #48915
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants