{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/10344","repository_url":"https://api.github.com/repos/nodejs/node","labels_url":"https://api.github.com/repos/nodejs/node/issues/10344/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/10344/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/10344/events","html_url":"https://github.com/nodejs/node/issues/10344","id":196502375,"number":10344,"title":"http: IncomingMessage not emitting 'end'","user":{"login":"mscdex","id":54666,"avatar_url":"https://avatars.githubusercontent.com/u/54666?v=3","gravatar_id":"","url":"https://api.github.com/users/mscdex","html_url":"https://github.com/mscdex","followers_url":"https://api.github.com/users/mscdex/followers","following_url":"https://api.github.com/users/mscdex/following{/other_user}","gists_url":"https://api.github.com/users/mscdex/gists{/gist_id}","starred_url":"https://api.github.com/users/mscdex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mscdex/subscriptions","organizations_url":"https://api.github.com/users/mscdex/orgs","repos_url":"https://api.github.com/users/mscdex/repos","events_url":"https://api.github.com/users/mscdex/events{/privacy}","received_events_url":"https://api.github.com/users/mscdex/received_events","type":"User","site_admin":false},"labels":[{"id":155267422,"url":"https://api.github.com/repos/nodejs/node/labels/http","name":"http","color":"c7def8","default":false},{"id":155435883,"url":"https://api.github.com/repos/nodejs/node/labels/stream","name":"stream","color":"c7def8","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-19T19:39:27Z","updated_at":"2016-12-19T19:58:23Z","closed_at":null,"body":"* **Version**: v4.5.0+\r\n* **Platform**: all\r\n* **Subsystem**: http\r\n\r\n@davidmarkclements brought to my attention an issue that came about in node v4.5.0 where an `http.IncomingMessage`'s `'end'` event wasn't being emitted properly when piping to a `stream.Writable`. The event *does* get emitted in node v4.4.7 however. Bisecting reveals https://github.com/nodejs/node/commit/6f312b3a9191709511054a8b8b7e663990d5413e as the offending commit.\r\n\r\nTest case:\r\n\r\n```js\r\nvar http = require('http');\r\nvar Writable = require('stream').Writable;\r\n\r\nhttp.createServer((req, res) => {\r\n  req.on('end', function() {\r\n    console.log('end');\r\n  });\r\n  var ws = new Writable({\r\n    write: function(data, enc, cb) {\r\n      cb();\r\n      this.emit('finish');\r\n    }\r\n  });\r\n  req.pipe(ws);\r\n}).listen(8080)\r\n```\r\n\r\nIt doesn't matter which order the `cb()` and `this.emit('finish')` are in or if the `emit()` is wrapped in a `process.nextTick()`. If `emit()` is wrapped in a `setImmediate()` though, then the `'end'` event gets emitted.\r\n\r\n/cc @trevnorris @indutny "},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/268062486","html_url":"https://github.com/nodejs/node/issues/10344#issuecomment-268062486","issue_url":"https://api.github.com/repos/nodejs/node/issues/10344","id":268062486,"user":{"login":"davidmarkclements","id":1190716,"avatar_url":"https://avatars.githubusercontent.com/u/1190716?v=3","gravatar_id":"","url":"https://api.github.com/users/davidmarkclements","html_url":"https://github.com/davidmarkclements","followers_url":"https://api.github.com/users/davidmarkclements/followers","following_url":"https://api.github.com/users/davidmarkclements/following{/other_user}","gists_url":"https://api.github.com/users/davidmarkclements/gists{/gist_id}","starred_url":"https://api.github.com/users/davidmarkclements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidmarkclements/subscriptions","organizations_url":"https://api.github.com/users/davidmarkclements/orgs","repos_url":"https://api.github.com/users/davidmarkclements/repos","events_url":"https://api.github.com/users/davidmarkclements/events{/privacy}","received_events_url":"https://api.github.com/users/davidmarkclements/received_events","type":"User","site_admin":false},"created_at":"2016-12-19T19:58:23Z","updated_at":"2016-12-19T19:58:23Z","body":"cc @mcollina "}}
{"actor":{"display_login":"davidmarkclements"}}