mscdex / node-ftp

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

TypeError: undefined is not a function when deleting a file #117

Closed jviotti closed 9 years ago

jviotti commented 9 years ago

I'm getting the following error when trying to delete a file:

/Users/jviotti/Projects/resin/resin-plugin-watch/node_modules/ftp/lib/connection.js:484
          return cb(makeError(code, 'Compression not supported'));
                 ^
TypeError: undefined is not a function
    at Object.cb (/Users/jviotti/Projects/resin/resin-plugin-watch/node_modules/ftp/lib/connection.js:484:18)
    at Parser.<anonymous> (/Users/jviotti/Projects/resin/resin-plugin-watch/node_modules/ftp/lib/connection.js:113:22)
    at Parser.EventEmitter.emit (events.js:98:17)
    at Parser._write (/Users/jviotti/Projects/resin/resin-plugin-watch/node_modules/ftp/lib/parser.js:59:10)
    at doWrite (_stream_writable.js:221:10)
    at writeOrBuffer (_stream_writable.js:211:5)
    at Parser.Writable.write (_stream_writable.js:180:11)
    at Socket.ondata (/Users/jviotti/Projects/resin/resin-plugin-watch/node_modules/ftp/lib/connection.js:273:20)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:746:14)
    at Socket.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at Socket.Readable.push (_stream_readable.js:127:10)
    at TCP.onread (net.js:526:21)

By activating debug, I see:

[connection] > 'DELE ./hey'
[connection] < '250 Delete operation successful.\r\n'
[parser] < '250 Delete operation successful.\r\n'
[parser] Response: code=250, buffer='Delete operation successful.'
[connection] > 'PASV'
[connection] < '227 Entering Passive Mode (192,168,2,7,120,134).\r\n'
[parser] < '227 Entering Passive Mode (192,168,2,7,120,134).\r\n'
[parser] Response: code=227, buffer='Entering Passive Mode (192,168,2,7,120,134).'
[connection] PASV socket connected
[connection] > 'MODE Z'
[connection] < '504 Bad MODE command.\r\n'
[parser] < '504 Bad MODE command.\r\n'
[parser] Response: code=504, buffer='Bad MODE command.'

As the stack trace shows, the errors happens on https://github.com/mscdex/node-ftp/blob/master/lib/connection.js#L484, which is inside the list function (https://github.com/mscdex/node-ftp/blob/master/lib/connection.js#L402).

By inspecting the arguments to .list() before the error is thrown I see that:

path = '.'
zcomp = 'Delete operation successful.'
cb = undefined

However, I was unable to find where .list() is called with such arguments when using the .delete() function.

jviotti commented 9 years ago

It was my fault while using async. Closing now.