{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/2156","repository_url":"https://api.github.com/repos/nodejs/node","labels_url":"https://api.github.com/repos/nodejs/node/issues/2156/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/2156/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/2156/events","html_url":"https://github.com/nodejs/node/issues/2156","id":94352681,"number":2156,"title":"Streams: req.on('end') is sometimes called, sometimes not","user":{"login":"iliakan","id":349336,"avatar_url":"https://avatars.githubusercontent.com/u/349336?v=3","gravatar_id":"","url":"https://api.github.com/users/iliakan","html_url":"https://github.com/iliakan","followers_url":"https://api.github.com/users/iliakan/followers","following_url":"https://api.github.com/users/iliakan/following{/other_user}","gists_url":"https://api.github.com/users/iliakan/gists{/gist_id}","starred_url":"https://api.github.com/users/iliakan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iliakan/subscriptions","organizations_url":"https://api.github.com/users/iliakan/orgs","repos_url":"https://api.github.com/users/iliakan/repos","events_url":"https://api.github.com/users/iliakan/events{/privacy}","received_events_url":"https://api.github.com/users/iliakan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nodejs/node/labels/confirmed-bug","name":"confirmed-bug","color":"fc2929"},{"url":"https://api.github.com/repos/nodejs/node/labels/http","name":"http","color":"c7def8"},{"url":"https://api.github.com/repos/nodejs/node/labels/stream","name":"stream","color":"c7def8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-07-10T17:32:15Z","updated_at":"2016-03-12T07:05:25Z","closed_at":null,"body":"Let's say I have a `server.on('request')` handler, with the code:\r\n\r\n```js\r\nreq\r\n      .setEncoding('utf-8')\r\n      .on('data', function(data) {\r\n        body += data;\r\n        if (body.length > 10) {\r\n          res.statusCode = 413;\r\n          res.end(\"Your message is too big for my little chat\");\r\n        }\r\n      })\r\n      .on('end', function() {\r\n        console.log(\"END\");\r\n      });\r\n```\r\n\r\nIf the message is too big (413) should `on('end')` event trigger?\r\n\r\nP.S. I'm asking because it does trigger in this case (10 bytes limit), but it does not trigger in the case of a larger limit (1000000 bytes limit). The behavior - sometimes it triggers and sometimes not - seems weird.\r\n    "},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/195676475","html_url":"https://github.com/nodejs/node/issues/2156#issuecomment-195676475","issue_url":"https://api.github.com/repos/nodejs/node/issues/2156","id":195676475,"user":{"login":"iliakan","id":349336,"avatar_url":"https://avatars.githubusercontent.com/u/349336?v=3","gravatar_id":"","url":"https://api.github.com/users/iliakan","html_url":"https://github.com/iliakan","followers_url":"https://api.github.com/users/iliakan/followers","following_url":"https://api.github.com/users/iliakan/following{/other_user}","gists_url":"https://api.github.com/users/iliakan/gists{/gist_id}","starred_url":"https://api.github.com/users/iliakan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iliakan/subscriptions","organizations_url":"https://api.github.com/users/iliakan/orgs","repos_url":"https://api.github.com/users/iliakan/repos","events_url":"https://api.github.com/users/iliakan/events{/privacy}","received_events_url":"https://api.github.com/users/iliakan/received_events","type":"User","site_admin":false},"created_at":"2016-03-12T07:05:25Z","updated_at":"2016-03-12T07:05:25Z","body":"Summarizing for your guys to triage more easily.\r\n\r\nAssuming that:\r\n\r\n- `end` triggers on full data consumption\r\n- `close` triggers on unexpected(only) connection drop\r\n\r\nIt is possible that if the data is not fully consumed and the connection is explicitly closed (for example, limit reached), then both events do not trigger.\r\n\r\nThat is \"an intended\", right?"}}