{"action":"created","issue":{"url":"https://api.github.com/repos/expressjs/body-parser/issues/112","labels_url":"https://api.github.com/repos/expressjs/body-parser/issues/112/labels{/name}","comments_url":"https://api.github.com/repos/expressjs/body-parser/issues/112/comments","events_url":"https://api.github.com/repos/expressjs/body-parser/issues/112/events","html_url":"https://github.com/expressjs/body-parser/issues/112","id":92416402,"number":112,"title":"Request Aborted Error","user":{"login":"slickplaid","id":25877,"avatar_url":"https://avatars.githubusercontent.com/u/25877?v=3","gravatar_id":"","url":"https://api.github.com/users/slickplaid","html_url":"https://github.com/slickplaid","followers_url":"https://api.github.com/users/slickplaid/followers","following_url":"https://api.github.com/users/slickplaid/following{/other_user}","gists_url":"https://api.github.com/users/slickplaid/gists{/gist_id}","starred_url":"https://api.github.com/users/slickplaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slickplaid/subscriptions","organizations_url":"https://api.github.com/users/slickplaid/orgs","repos_url":"https://api.github.com/users/slickplaid/repos","events_url":"https://api.github.com/users/slickplaid/events{/privacy}","received_events_url":"https://api.github.com/users/slickplaid/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/expressjs/body-parser/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":{"login":"dougwilson","id":67512,"avatar_url":"https://avatars.githubusercontent.com/u/67512?v=3","gravatar_id":"","url":"https://api.github.com/users/dougwilson","html_url":"https://github.com/dougwilson","followers_url":"https://api.github.com/users/dougwilson/followers","following_url":"https://api.github.com/users/dougwilson/following{/other_user}","gists_url":"https://api.github.com/users/dougwilson/gists{/gist_id}","starred_url":"https://api.github.com/users/dougwilson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dougwilson/subscriptions","organizations_url":"https://api.github.com/users/dougwilson/orgs","repos_url":"https://api.github.com/users/dougwilson/repos","events_url":"https://api.github.com/users/dougwilson/events{/privacy}","received_events_url":"https://api.github.com/users/dougwilson/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2015-07-01T15:41:06Z","updated_at":"2015-07-01T16:28:18Z","closed_at":null,"body":"Apologies if this is an easily solvable issue, but I seem to not be able to properly catch the \"request aborted\" error thrown in a JSON body POST/PUT.\r\n\r\nI've reference issue #93 and understand that it's purpose is to keep the connection from hanging, but when I encounter it, the request doesn't make it down to where Express should be handling the error. It is thrown much earlier in the stack.\r\n\r\nExample exception:\r\n```\r\nError: request aborted\r\n    at makeError (/home/ra/xx/node_modules/body-parser/node_modules/raw-body/index.js:139:15)\r\n    at IncomingMessage.onAborted (/home/ra/xx/node_modules/body-parser/node_modules/raw-body/index.js:237:10)\r\n    at IncomingMessage.emit (events.js:92:17)\r\n    at abortIncoming (http.js:1916:11)\r\n    at CleartextStream.serverSocketCloseListener (http.js:1928:5)\r\n    at CleartextStream.emit (events.js:117:20)\r\n    at tls.js:694:10\r\n    at process._tickCallback (node.js:442:13)\r\n```\r\n\r\nI am using version `1.13.1` and using an encrypted `HTTPS` connection through Express 4.\r\n\r\nMy usage of `body-parser` in the appropriate Express routes:\r\n`bodyParser.json({ parameterLimit: 100, limit: '1mb' })`\r\n`bodyParser.urlencoded({ extended: true, parameterLimit: 100, limit: '1mb' })`\r\n\r\nWe have a rather large form that has an autosave feature. In the XHR request, if they make two quick changes, we'll abort the previous request purposely and resubmit with the new data. In some circumstances this causes the whole body not to be sent, and the above error thrown.\r\n\r\nMy error condition in Express 4 is as follows (simplified from production):\r\n```javascript\r\n  app.use(function(err, req, res, next){\r\n      if(err.status && err.status < 500) {\r\n        return res.status(400).send('Request Aborted');\r\n      }\r\n\r\n      console.log('Type of Error:', typeof err);\r\n      console.log('Error: ', err.stack);\r\n\r\n      if(req.xhr) {\r\n        res.partial('500', { error: err });\r\n      } else {\r\n        res.render('500', { error: err });\r\n      }\r\n  });\r\n```\r\n\r\nNothing I do there seems to matter as the error is being thrown much earlier than that express exception handling.\r\n\r\nAm I doing something wrong, or might there be something I'm not following in the code to make that happen?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/expressjs/body-parser/issues/comments/117738270","html_url":"https://github.com/expressjs/body-parser/issues/112#issuecomment-117738270","issue_url":"https://api.github.com/repos/expressjs/body-parser/issues/112","id":117738270,"user":{"login":"dougwilson","id":67512,"avatar_url":"https://avatars.githubusercontent.com/u/67512?v=3","gravatar_id":"","url":"https://api.github.com/users/dougwilson","html_url":"https://github.com/dougwilson","followers_url":"https://api.github.com/users/dougwilson/followers","following_url":"https://api.github.com/users/dougwilson/following{/other_user}","gists_url":"https://api.github.com/users/dougwilson/gists{/gist_id}","starred_url":"https://api.github.com/users/dougwilson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dougwilson/subscriptions","organizations_url":"https://api.github.com/users/dougwilson/orgs","repos_url":"https://api.github.com/users/dougwilson/repos","events_url":"https://api.github.com/users/dougwilson/events{/privacy}","received_events_url":"https://api.github.com/users/dougwilson/received_events","type":"User","site_admin":false},"created_at":"2015-07-01T16:28:18Z","updated_at":"2015-07-01T16:28:18Z","body":"Perhaps another thing you can do is explain how you know your error handler is not being called? It's important to note that under a request abort condition in Node.js, you cannot write a response to the client, because the TCP connection is already closed. Are you basing your error handler calling off those two `console.log` statements, or what the HTTP behavior is?"}}