mikeal / sequest

Simplified API for SSH and SFTP similar to request.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No way to handle connection errors

jcrugzz opened this issue · comments

If the error does not occur on the connection.exec call in ssh2, there is no way to handle the error. This type of error occurs when there is a connection timeout when trying to SSH into a server and things of that nature.

This specifically applies to the sequest.connect() method as it creates a persistent connection that has no way to handle errors.

@mikeal What do you think a good solution to this would be? Im currently working around this by creating my own connection and then binding that to a sequest instance, but this is sub-ideal.

The return value from sequest.connect() could become an event emitter and we could proxy all errors to it. We should do the same thing in each sequest instance but we'll have to be good about removing the error handler at some point.

If we bound an error handler prior to onConnectionReady and remove it before processing exec can you think of any cases where we might still get errors?

just realized the return value has to be a function so we have to do onError the same way we have onCall (which is honestly a better pattern but certainly not the dominant pattern in node).