I'm downloading all the files from a remote server folder with sftp.fastGet().
Everything runs fine when working with roughly a hundred downloads.
When using a folder with around 40000 files Node emits this warning:
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added. Use emitter.setMaxListeners() to increase limit
at _addListener (events.js:280:19)
at Deflate.addListener (events.js:297:10)
at Deflate.Readable.on (_stream_readable.js:772:35)
at Deflate.once (events.js:341:8)
at Deflate.flush (zlib.js:346:12)
at send (C:\Users\radaemarco\Documents\node\mongodb-news-container\src\retriever\node_modules\ssh2-streams\lib\ssh.js:5269:14)
at SSH2Stream.channelData (C:\Users\radaemarco\Documents\node\mongodb-news-container\src\retriever\node_modules\ssh2-streams\lib\ssh.js:941:10)
at Channel._write (C:\Users\radaemarco\Documents\node\mongodb-news-container\src\retriever\node_modules\ssh2\lib\Channel.js:345:21)
at doWrite (_stream_writable.js:387:12)
at writeOrBuffer (_stream_writable.js:373:5)
Actually, the downloadFile() is controlled by a database query result so there's potentially a callback / promise step in between that's not shown here.
Moreover, I tried adding all the downloadFile() in a chain of promises:
This could be caused from my own code of course.
I'm downloading all the files from a remote server folder with
sftp.fastGet()
. Everything runs fine when working with roughly a hundred downloads.When using a folder with around 40000 files Node emits this warning:
Here's a stripped down version of my code:
Actually, the
downloadFile()
is controlled by a database query result so there's potentially a callback / promise step in between that's not shown here.Moreover, I tried adding all the
downloadFile()
in a chain of promises:but I'm still get that warning.
Any hint? Am I doing something wrong?