{"action":"created","issue":{"url":"https://api.github.com/repos/caolan/highland/issues/489","repository_url":"https://api.github.com/repos/caolan/highland","labels_url":"https://api.github.com/repos/caolan/highland/issues/489/labels{/name}","comments_url":"https://api.github.com/repos/caolan/highland/issues/489/comments","events_url":"https://api.github.com/repos/caolan/highland/issues/489/events","html_url":"https://github.com/caolan/highland/issues/489","id":151329688,"number":489,"title":"how to destroy a stream cleanly","user":{"login":"benjaminhon","id":8186376,"avatar_url":"https://avatars.githubusercontent.com/u/8186376?v=3","gravatar_id":"","url":"https://api.github.com/users/benjaminhon","html_url":"https://github.com/benjaminhon","followers_url":"https://api.github.com/users/benjaminhon/followers","following_url":"https://api.github.com/users/benjaminhon/following{/other_user}","gists_url":"https://api.github.com/users/benjaminhon/gists{/gist_id}","starred_url":"https://api.github.com/users/benjaminhon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjaminhon/subscriptions","organizations_url":"https://api.github.com/users/benjaminhon/orgs","repos_url":"https://api.github.com/users/benjaminhon/repos","events_url":"https://api.github.com/users/benjaminhon/events{/privacy}","received_events_url":"https://api.github.com/users/benjaminhon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-27T08:40:28Z","updated_at":"2016-04-28T02:31:11Z","closed_at":null,"body":"Hi All, here is my issue\r\n\r\n**many clients will connect and pipe their data into mainStream**\r\n```\r\nnet.createServer (socket) ->\r\n    clientStream = h(socket)\r\n    clientStream.fork().pipe mainStream\r\n```\r\nHowever, my question is what happens the the socket closes, does highland destroys clientStream and unpipes it from mainStream?\r\n\r\nWhen i disconnect and connect the client 11 times i get this warning:\r\n```\r\n(node) warning: possible EventEmitter memory leak detected. 11 drain listeners added. Use emitter.setMaxListeners() to increase limit.\r\nTrace\r\n    at Stream.addListener (events.js:239:17)\r\n    at pipeStream (/Users/benjaminhon/Developer/IndoorLocalization/server/localization-server/node_modules/highland/lib/index.js:501:10)\r\n    at Stream.pipe (/Users/benjaminhon/Developer/IndoorLocalization/server/localization-server/node_modules/highland/lib/index.js:1008:12)\r\n```\r\n\r\nit seems some event listeners are not removed? do i need to do this manually and unripe manually?\r\n\r\nThx\r\n"},"comment":{"url":"https://api.github.com/repos/caolan/highland/issues/comments/215290379","html_url":"https://github.com/caolan/highland/issues/489#issuecomment-215290379","issue_url":"https://api.github.com/repos/caolan/highland/issues/489","id":215290379,"user":{"login":"benjaminhon","id":8186376,"avatar_url":"https://avatars.githubusercontent.com/u/8186376?v=3","gravatar_id":"","url":"https://api.github.com/users/benjaminhon","html_url":"https://github.com/benjaminhon","followers_url":"https://api.github.com/users/benjaminhon/followers","following_url":"https://api.github.com/users/benjaminhon/following{/other_user}","gists_url":"https://api.github.com/users/benjaminhon/gists{/gist_id}","starred_url":"https://api.github.com/users/benjaminhon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjaminhon/subscriptions","organizations_url":"https://api.github.com/users/benjaminhon/orgs","repos_url":"https://api.github.com/users/benjaminhon/repos","events_url":"https://api.github.com/users/benjaminhon/events{/privacy}","received_events_url":"https://api.github.com/users/benjaminhon/received_events","type":"User","site_admin":false},"created_at":"2016-04-28T02:31:10Z","updated_at":"2016-04-28T02:31:10Z","body":"Hi victor, \r\n\r\nyep, its only 1 client. Yea there is no way that i can ensure that END happens before CLOSE, as the device might crash or terminated without closing the socket properly. I've noticed that sometimes CLOSE happens and END does not happen.\r\n"}}