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

MaxListenersExceededWarning: Possible EventTarget memory leak detected #3674

Open
2 tasks done
GMZwinge opened this issue Jan 7, 2025 · 0 comments
Open
2 tasks done

Comments

@GMZwinge
Copy link
Contributor

GMZwinge commented Jan 7, 2025

Description

  • Node.js version: 18.20.4
  • Gitbeaker version: 40.4.0
  • Gitbeaker release (cli, rest, core, requester-utils): rest, core, requester-utils
  • OS & version: CentOS 8

Calling a GitLab API that returns a large number of pages (eg: Commits.allReferences(...) or Events.all(...)) can result in warnings like this:

(node:<nnnnn>) MaxListenersExceededWarning: Possible EventTarget memory leak detected. <nnn> abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)

Running with --trace-warnings gives a stack trace like this:

(node:<nnnnn>) MaxListenersExceededWarning: Possible EventTarget memory leak detected. <nnn> abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit
    at [kNewListener] (node:internal/event_target:516:17)
    at [kNewListener] (node:internal/abort_controller:189:24)
    at EventTarget.addEventListener (node:internal/event_target:625:23)
    at new Request (node:internal/deps/undici/undici:7182:20)
    at defaultRequestHandler (/<path>/node_modules/@gitbeaker/rest/dist/index.js:86:21)
    at requester.<computed> [as get] (/<path>/node_modules/@gitbeaker/requester-utils/dist/index.js:81:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getManyMore (/<path>/node_modules/@gitbeaker/core/dist/index.js:76:26)
    at async <className>.<functionName> (/<path>/<basename>.js:<nnn>:<nn>)

where <className>.<functionName> is a function calling a gitlab API that returns a large number of pages.

Steps to reproduce

Call Commits.allReferences(...) on the commit id for a branch that returns 60,000 or more refs, eg: a branch that was created on main/master without any commit on that branch before large number of refs (60,000 or more branch, tags, etc...) were pushed on main/master.

Expected behaviour

No warning.

Actual behaviour

Warning: MaxListenersExceededWarning.

Possible fixes

Provide a capability to call EventTarget.setMaxListeners(...) on the EventTarget that Request in undici uses.

Checklist

  • I have checked that this is not a duplicate issue.
  • I have read the documentation.
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

No branches or pull requests

1 participant