Skip to content

jsftp intermittently skips end event on socket #106

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

Closed
doronin opened this issue Oct 29, 2014 · 3 comments
Closed

jsftp intermittently skips end event on socket #106

doronin opened this issue Oct 29, 2014 · 3 comments

Comments

@doronin
Copy link

doronin commented Oct 29, 2014

When getting file using Ftp.prototype.get socket intermittently emits close event without emitting end event. This causes downstream consumers (like https://github.com/sergi/jsftp/blob/master/lib/jsftp.js#L438) to hang until timeout kicks in.

@doronin
Copy link
Author

doronin commented Oct 29, 2014

Observed behavior:

FTP DEBUG:  response
{
  "code": 226,
  "text": "226 Transfer complete.",
  "isMark": false,
  "isError": false
}
ftp socket emits `close`

Expected behavior:

FTP DEBUG:  response
{
  "code": 226,
  "text": "226 Transfer complete.",
  "isMark": false,
  "isError": false
}
ftp socket emits `end`
ftp socket emits `close`

@theo-armour
Copy link

Maybe my issue is related, but not sure as this is all way above my pay grade.

When I run the sample list or get examples, I am left with a blinking cursor and not at the command prompt.

No big deal. I've been able to get the files off a server I needed. All I do is hit control-C.

But it would be nice to know what to do to terminate the script.

In any case: Bravo Sergi for making my life a lot easier. Thank you!

@sergi
Copy link
Owner

sergi commented Dec 22, 2014

Hey @doronin, this scenario can happen when the socket is closed due to an error (http://nodejs.org/api/net.html#net_event_error_1). In that case, an error event will be emitted immediately followed by a close event with a boolean true parameter.

So, one way to see if that's what's happening is to listen to the close event and see if it comes with a parameter with value true. Can you try this in your scenario? Thanks!

@sergi sergi closed this as completed in 1be5e7b Dec 23, 2014
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