title: how do I send (put) multiple files using nodejs ssh2-sftp-client?
body: <p>If I try more then 10 files I got the warning, but the other files are not uploaded, I cannot upload more than 10 files. What am I doing wrong?</p>
  
  <blockquote>
    <p>{ node:17472) MaxListenersExceededWarning: Possible EventEmitter
    memory leak detected. 11 ready listeners added. Use
    emitter.setMaxListeners() to increase limit (node:17472)
    MaxListenersExceededWarning: Possible EventEmitter memory leak
    detected. 11 error listeners added. Use emitter.setMaxListeners() to
    increase limit (node:17472) MaxListenersExceededWarning: Possible
    EventEmitter memory leak detected. 11 close listeners added. Use
    emitter.setMaxListeners() to increase limit }</p>
  </blockquote>
  
  <pre><code> let Client = require('ssh2-sftp-client');
      let sftp = new Client();
      var promises = [];
      for(var i=0; i &lt; 12; i++) {
          promises.push(sendFile(sftp, req.body, results.romlist[i].filename));
      }
      Promise.all(promises).then(function() {
          sftp.end();
          res.send('{"message":"OK"}');
      });
        const sendFile = (sftp, config, filename) =&gt; {
  console.log(filename);
  return sftp.connect(config).then(() =&gt; {
      return sftp.put(filename, "/home/pi/RetroPie/roms/atari2600/" + filename.substr(filename.lastIndexOf('/')+1));
  }).catch((err) =&gt; {
      console.log(err, 'catch error');
  });};
  </code></pre>