{"action":"created","issue":{"url":"https://api.github.com/repos/mscdex/ssh2/issues/176","labels_url":"https://api.github.com/repos/mscdex/ssh2/issues/176/labels{/name}","comments_url":"https://api.github.com/repos/mscdex/ssh2/issues/176/comments","events_url":"https://api.github.com/repos/mscdex/ssh2/issues/176/events","html_url":"https://github.com/mscdex/ssh2/issues/176","id":43982818,"number":176,"title":"SFTP readdir() throws asynchronously","user":{"login":"afri","id":137912,"avatar_url":"https://avatars.githubusercontent.com/u/137912?v=3","gravatar_id":"","url":"https://api.github.com/users/afri","html_url":"https://github.com/afri","followers_url":"https://api.github.com/users/afri/followers","following_url":"https://api.github.com/users/afri/following{/other_user}","gists_url":"https://api.github.com/users/afri/gists{/gist_id}","starred_url":"https://api.github.com/users/afri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afri/subscriptions","organizations_url":"https://api.github.com/users/afri/orgs","repos_url":"https://api.github.com/users/afri/repos","events_url":"https://api.github.com/users/afri/events{/privacy}","received_events_url":"https://api.github.com/users/afri/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2014-09-26T00:13:41Z","updated_at":"2015-01-09T16:55:03Z","closed_at":null,"body":"I have the following situation:\r\n- I perform several readdir() calls concurrently.\r\n- From one of the readdir() calls I terminate the SFTP session by calling end(). Some of readdir() calls within the same session are still pending at this point.\r\nThe following asynchronous exception is thrown:\r\n\r\nUncaught: Error: write after end\r\nError: write after end\r\n    at writeAfterEnd (_stream_writable.js:133:12)\r\n    at ChannelStream.Writable.write (_stream_writable.js:181:5)\r\n    at SFTP._send (c:\\Users\\Alexander\\devel\\conductance\\node_modules\\ssh2\\lib\\SF\r\nTP\\SFTPv3.js:1017:23)\r\n    at SFTP.readdir (c:\\Users\\Alexander\\devel\\conductance\\node_modules\\ssh2\\lib\\\r\nSFTP\\SFTPv3.js:710:15)\r\n    at reread (c:\\Users\\Alexander\\devel\\conductance\\node_modules\\ssh2\\lib\\SFTP\\S\r\nFTPv3.js:680:12)\r\n    at c:\\Users\\Alexander\\devel\\conductance\\node_modules\\ssh2\\lib\\SFTP\\SFTPv3.js\r\n:694:9\r\n    at c:\\Users\\Alexander\\devel\\conductance\\node_modules\\ssh2\\lib\\SFTP\\SFTPv3.js\r\n:717:5\r\n    at SFTP._parse (c:\\Users\\Alexander\\devel\\conductance\\node_modules\\ssh2\\lib\\S\r\nFTP\\SFTPv3.js:1176:13)\r\n    at ChannelStream.<anonymous> (c:\\Users\\Alexander\\devel\\conductance\\node_modu\r\nles\\ssh2\\lib\\SFTP\\SFTPv3.js:72:10)\r\n    at ChannelStream.EventEmitter.emit (events.js:95:17)\r\n\r\n\r\nInterpretation: After calling end(), there is still readable data from the socket, which the module passes to _parse(), and then, when while acting on that data, the module writes to the socket which is not happy to be written to."},"comment":{"url":"https://api.github.com/repos/mscdex/ssh2/issues/comments/69362682","html_url":"https://github.com/mscdex/ssh2/issues/176#issuecomment-69362682","issue_url":"https://api.github.com/repos/mscdex/ssh2/issues/176","id":69362682,"user":{"login":"lchampagnie","id":1915293,"avatar_url":"https://avatars.githubusercontent.com/u/1915293?v=3","gravatar_id":"","url":"https://api.github.com/users/lchampagnie","html_url":"https://github.com/lchampagnie","followers_url":"https://api.github.com/users/lchampagnie/followers","following_url":"https://api.github.com/users/lchampagnie/following{/other_user}","gists_url":"https://api.github.com/users/lchampagnie/gists{/gist_id}","starred_url":"https://api.github.com/users/lchampagnie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lchampagnie/subscriptions","organizations_url":"https://api.github.com/users/lchampagnie/orgs","repos_url":"https://api.github.com/users/lchampagnie/repos","events_url":"https://api.github.com/users/lchampagnie/events{/privacy}","received_events_url":"https://api.github.com/users/lchampagnie/received_events","type":"User","site_admin":false},"created_at":"2015-01-09T16:55:03Z","updated_at":"2015-01-09T16:55:03Z","body":"Did you find a solution for this? I'm having the same problem while trying to read from dir in a cascaded callbacks."}}