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

Issue/Suggestion :- Adding of maxEventListner on all the event #1373

Open
abhishekglb opened this issue Mar 1, 2024 · 4 comments
Open

Issue/Suggestion :- Adding of maxEventListner on all the event #1373

abhishekglb opened this issue Mar 1, 2024 · 4 comments

Comments

@abhishekglb
Copy link

Hello,

I am currently using a Node.js package (https://www.npmjs.com/package/ssh2-sftp-client) that utilizes another package (https://www.npmjs.com/package/ssh2).

Recently, I have been encountering the following memory leak error on my production environment:
"Possible Event Emitter memory leak detected. 10 close/end listeners added to [Client]. Use setMaxEventListener to increase the limit."

This error occurs frequently when multiple SFTP users are accessing the system. I was wondering if it's possible to add "_this.setMaxListeners(0);" to address this issue.

Thank you for your assistance. Please let me know if this update can be implemented.

@abhishekglb abhishekglb changed the title Adding of maxEventListner on all the event Issue/Suggestion :- Adding of maxEventListner on all the event Mar 1, 2024
@mscdex
Copy link
Owner

mscdex commented Mar 1, 2024

Can you reproduce the issue using only ssh2 and using a minimal example? That should rule out any downstream issues or issues with the code utilizing ssh2/ssh2-sftp-client.

@theophilusx
Copy link

theophilusx commented Mar 1, 2024 via email

@abhishekglb
Copy link
Author

abhishekglb commented Mar 4, 2024

So, my current use case is as follows:
I have multiple SFTP connections per user, and multiple users try to upload files from their configured SFTP.
So, I have created an SFTP object like this:

let sftp_user = {};

sftp_user[user_id] = new SftpClient();

// Your file upload process here

delete sftp_user[user_id];

In this setup, the file upload process starts by verifying the FileSystemDirectory, and once the file is successfully uploaded, then connection is closed.

@theophilusx
Copy link

theophilusx commented Mar 4, 2024 via email

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

3 participants