mscdex / node-ftp

An FTP client module for node.js
MIT License
1.13k stars 243 forks source link

Uncatchable error #67

Closed drzax closed 11 years ago

drzax commented 11 years ago

I'm getting the following error:

TypeError: Cannot call method 'end' of undefined
    at reentry (/Users/elverys7d/Documents/news-dev/infoplum-connector/node_modules/ftp/lib/connection.js:184:29)
    at Parser.<anonymous> (/Users/elverys7d/Documents/news-dev/infoplum-connector/node_modules/ftp/lib/connection.js:108:22)
    at EventEmitter.emit (events.js:98:17)
    at Parser._write (/Users/elverys7d/Documents/news-dev/infoplum-connector/node_modules/ftp/lib/parser.js:57:10)
    at doWrite (/Users/elverys7d/Documents/news-dev/infoplum-connector/node_modules/ftp/node_modules/readable-stream/lib/_stream_writable.js:211:10)
    at writeOrBuffer (/Users/elverys7d/Documents/news-dev/infoplum-connector/node_modules/ftp/node_modules/readable-stream/lib/_stream_writable.js:201:5)
    at Writable.write (/Users/elverys7d/Documents/news-dev/infoplum-connector/node_modules/ftp/node_modules/readable-stream/lib/_stream_writable.js:172:11)
    at ondata (/Users/elverys7d/Documents/news-dev/infoplum-connector/node_modules/ftp/lib/connection.js:260:20)

The relevant block of connect.js is with the error thrown on the return self._socket.end();:

      if (err && (!cmd || cmd === 'USER' || cmd === 'PASS' || cmd === 'TYPE')) {
        self.emit('error', err);
        return self._socket.end();
      }

As far as I can tell, there's no way to catch this error (aside from catching uncaught exceptions at the process level, which isn't ideal).

mscdex commented 11 years ago

Should be fixed with 007d1951d. Can you try the master branch?: npm install https://github.com/mscdex/node-ftp/tarball/master

drzax commented 11 years ago

Love your work. Cheers.