aws-sdk-js-v3: [Bug client-s3]: MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
Checkboxes for prior research
- I’ve gone through Developer Guide and API reference
- I’ve checked AWS Forums and StackOverflow.
- I’ve searched for previous similar issues and didn’t find any solution.
Describe the bug
I was following this guide: https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/nodegetstarted
and I got the following warning: MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit.
The code succeeded though. Is the warning critical?
SDK version number
@aws-sdk/client-s3@3.370.0
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v20.4.0
Reproduction Steps
Follow the instruction in this README file.
Observed Behavior
Warning message: (node:35080) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(Use node --trace-warnings ... to show where the warning was created)
Expected Behavior
No warning
Possible Solution
The client-s3 module might be leaking memory.
This is a minimal code to reproduce the issue:
import { CreateBucketCommand, S3Client } from '@aws-sdk/client-s3'
const s3Client = new S3Client({ region: 'us-east-1' })
const data = await s3Client.send(
new CreateBucketCommand({ Bucket: 'PUT_BUCKET_NAME_HERE' })
)
console.log(data)
You can try to run it and will see the warning even if the bucket creation succeeds.
Additional Information/Context
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 7
- Comments: 16 (2 by maintainers)
I am also facing the same issue with Node v20.7.0
(node:15116) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limitA year since this issue was opened, and the issue is still there with the latest NPM install and Node 20.
facing the same issue with Node v20.9.0
@yenfryherrerafeliz I’m still getting the error:
This is the code I tried:
Then run with:
Versions: @aws-sdk/client-s3:
v3.398.0node:v20.5.1UPDATE: When testing on Node.js version 18, no problems were encountered. Not sure if this will help!
Hello, the same problem with Node v20.9.0 in:
I have the same exact error, but I’m not using AWS. I’m doing an
npm install. Maybe some package (or npm itself?) is trying to use network during install and causing the warning.It seems harmless though. Like, even if code is written properly, if some code is, for example, sending more than 10 requests and has properly added more than 10 event handlers for each of those requests (just guessing here) then it is plausible to see this error, but it won’t actually mean anything is wrong.
This is as if a DOM API like
window.addEventListener('whatever', listener)would automatically log a warning to console after an arbitrary 10 event listeners were added, even if they were all totally valid listeners.There’s probably nothing to do here, and just hope the codes that are adding listeners (could be more than one package in the system, so it could add up) are properly removing listeners when they’re done.
If you are the one adding listeners in your own code, then this warning could actually be useful if you didn’t expect listeners to keep growing.
This warning is probably just useless noise most likely.