{"action":"created","issue":{"url":"https://api.github.com/repos/ArnoldZokas/grunt-ssh-multi-exec/issues/6","labels_url":"https://api.github.com/repos/ArnoldZokas/grunt-ssh-multi-exec/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/ArnoldZokas/grunt-ssh-multi-exec/issues/6/comments","events_url":"https://api.github.com/repos/ArnoldZokas/grunt-ssh-multi-exec/issues/6/events","html_url":"https://github.com/ArnoldZokas/grunt-ssh-multi-exec/issues/6","id":59189073,"number":6,"title":"Async error: Callback was already called","user":{"login":"ironblock","id":5800173,"avatar_url":"https://avatars.githubusercontent.com/u/5800173?v=3","gravatar_id":"","url":"https://api.github.com/users/ironblock","html_url":"https://github.com/ironblock","followers_url":"https://api.github.com/users/ironblock/followers","following_url":"https://api.github.com/users/ironblock/following{/other_user}","gists_url":"https://api.github.com/users/ironblock/gists{/gist_id}","starred_url":"https://api.github.com/users/ironblock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ironblock/subscriptions","organizations_url":"https://api.github.com/users/ironblock/orgs","repos_url":"https://api.github.com/users/ironblock/repos","events_url":"https://api.github.com/users/ironblock/events{/privacy}","received_events_url":"https://api.github.com/users/ironblock/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-27T04:45:36Z","updated_at":"2015-03-23T22:03:28Z","closed_at":null,"body":"I'm noticing this periodically on a few different machines:\r\n\r\n```javascript\r\nFatal error: Callback was already called.\r\n       Error: Callback was already called.\r\n       at /usr/home/corey/fn10/src/gui/node_modules/grunt-ssh-multi-exec/node_modules/async/lib/async.js:30:31\r\n       at next (/usr/home/corey/fn10/src/gui/node_modules/grunt-ssh-multi-exec/tasks/ssh-multi-exec.js:86:33)\r\n       at /usr/home/corey/fn10/src/gui/node_modules/grunt-ssh-multi-exec/tasks/ssh-multi-exec.js:107:33\r\n       at start-server._.assign.commands.success \r\n            (/usr/home/corey/fn10/src/gui/grunt_tasks/config/ssh-multi-exec.js:210:15)\r\n       at ChannelStream.<anonymous> (/usr/home/corey/fn10/src/gui/node_modules/grunt-ssh-multi-exec/tasks/ssh-multi-exec.js:106:29)\r\n       at ChannelStream.emit (events.js:104:17)\r\n       at /usr/home/corey/fn10/src/gui/node_modules/grunt-ssh-multi-exec/node_modules/ssh2/lib/Channel.js:583:16\r\n       at process._tickCallback (node.js:355:11)\r\n```\r\n\r\nBased on that, I think it's something to do with how `next()` is called in the `else`, when the stream closes.\r\n\r\nSome quick googling shows similar problems where the async callback is called in an `if` and its `else`, but that doesn't seem to apply here.\r\n\r\nI've got grunt-ssh-multi-exec triggered by the completion of a build step - we're developing on an embedded appliance, so it builds, rsyncs the app over, and then runs ssh-multi-exec to get into the box and kick the webserver service.\r\n\r\nTo that end, my code on line 210 is:\r\n\r\n```javascript\r\n        , { input: \"/usr/sbin/service gui restart\"\r\n          , success: function( data, context, done ) {\r\n              logSshMsg( \"Issuing service restart command\", \"cyan\" );\r\n              printServerAddress( \"starting\" );\r\n              done();\r\n            }\r\n          , error: function( error, context, done ) {\r\n              printServerAddress( \"YOU WERE THE CHOSEN ONE\" );\r\n              done();\r\n            }\r\n          }\r\n```\r\n\r\nThe whole file is here:\r\nhttps://github.com/freenas/freenas/blob/freenas10/development/src/gui/grunt_tasks/config/ssh-multi-exec.js\r\n\r\nI'm happy to provide any other help I can. :)"},"comment":{"url":"https://api.github.com/repos/ArnoldZokas/grunt-ssh-multi-exec/issues/comments/85223363","html_url":"https://github.com/ArnoldZokas/grunt-ssh-multi-exec/issues/6#issuecomment-85223363","issue_url":"https://api.github.com/repos/ArnoldZokas/grunt-ssh-multi-exec/issues/6","id":85223363,"user":{"login":"ironblock","id":5800173,"avatar_url":"https://avatars.githubusercontent.com/u/5800173?v=3","gravatar_id":"","url":"https://api.github.com/users/ironblock","html_url":"https://github.com/ironblock","followers_url":"https://api.github.com/users/ironblock/followers","following_url":"https://api.github.com/users/ironblock/following{/other_user}","gists_url":"https://api.github.com/users/ironblock/gists{/gist_id}","starred_url":"https://api.github.com/users/ironblock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ironblock/subscriptions","organizations_url":"https://api.github.com/users/ironblock/orgs","repos_url":"https://api.github.com/users/ironblock/repos","events_url":"https://api.github.com/users/ironblock/events{/privacy}","received_events_url":"https://api.github.com/users/ironblock/received_events","type":"User","site_admin":false},"created_at":"2015-03-23T22:03:28Z","updated_at":"2015-03-23T22:03:28Z","body":"Awesome - I'll put a ticket on the stack for us to update our build tools, and I'll let you know what ends up happening. Our remote developers will be very happy if this fixes the problem. :)"}}