-
-
Notifications
You must be signed in to change notification settings - Fork 320
Description
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.