{"action":"closed","issue":{"url":"https://api.github.com/repos/feathersjs/express/issues/21","repository_url":"https://api.github.com/repos/feathersjs/express","labels_url":"https://api.github.com/repos/feathersjs/express/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/feathersjs/express/issues/21/comments","events_url":"https://api.github.com/repos/feathersjs/express/issues/21/events","html_url":"https://github.com/feathersjs/express/issues/21","id":295932426,"number":21,"title":"Error in error hook results in unhandled rejection","user":{"login":"MitMaro","id":177427,"avatar_url":"https://avatars1.githubusercontent.com/u/177427?v=4","gravatar_id":"","url":"https://api.github.com/users/MitMaro","html_url":"https://github.com/MitMaro","followers_url":"https://api.github.com/users/MitMaro/followers","following_url":"https://api.github.com/users/MitMaro/following{/other_user}","gists_url":"https://api.github.com/users/MitMaro/gists{/gist_id}","starred_url":"https://api.github.com/users/MitMaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MitMaro/subscriptions","organizations_url":"https://api.github.com/users/MitMaro/orgs","repos_url":"https://api.github.com/users/MitMaro/repos","events_url":"https://api.github.com/users/MitMaro/events{/privacy}","received_events_url":"https://api.github.com/users/MitMaro/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-02-09T16:37:32Z","updated_at":"2018-02-10T18:35:33Z","closed_at":"2018-02-10T18:35:33Z","author_association":"NONE","body":"Related to #19 in that it has a similar error, but is triggered by a different mechanism.\r\n\r\n### Steps to reproduce\r\n\r\nCreate an application with an application error hook that throws an error, and a single service that throws an error to trigger the hook. Call the endpoint with Curl.\r\n\r\n#### Reduced test case\r\n\r\nSee gist: https://gist.github.com/MitMaro/1b6016902e8eb965c63c738c939b0731\r\n\r\n```javascript\r\nconst feathers = require('@feathersjs/feathers');\r\nconst express = require('@feathersjs/express');\r\nconst app = express(feathers());\r\napp.configure(express.rest());\r\napp.hooks({\r\n\terror: () => {\r\n\t\tconsole.log('Throwing error in error hook');\r\n\t\tthrow new Error('Simulated error');\r\n\t}\r\n})\r\napp.use('/myservice', {\r\n\tasync find(data, params) {\r\n\t\t// trigger error hook\r\n\t\tthrow new Error();\r\n\t},\r\n});\r\napp.listen(3030);\r\nconsole.log('Feathers app started on 127.0.0.1:3030');\r\n\r\n```\r\n\r\n### Expected behavior\r\n\r\nAn error in an error hook should not show a warning about an unhandled promise, and there should be some response to the client. A `TypeError` caused by attempting to assign a property to `null` caused the issue in my project proper. \r\n\r\n### Actual behavior\r\n\r\nA unhandled rejection warning is displayed, and no response occurs.\r\n\r\n**Console 1**:\r\n\r\n```shell\r\n$ node index.js\r\nFeathers app started on 127.0.0.1:3030\r\nThrowing error in error hook\r\n(node:23416) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): TypeError: Cannot read property 'message' of undefined\r\n(node:23416) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.\r\n```\r\n\r\n**Console 2**:\r\n```shell\r\n$ curl 127.0.0.1:3030/myservice\r\n```\r\n\r\nBy adding a `unhandledRejection` handler:\r\n\r\n```javascript\r\nprocess.on('unhandledRejection', (reason, p) => {\r\n\tconsole.error('Unhandled Rejection');\r\n\tconsole.error(reason);\r\n});\r\n```\r\n\r\nThe following is returned:\r\n\r\n```\r\nUnhandled Rejection\r\nTypeError: Cannot read property 'message' of undefined\r\n    at service.(anonymous function).then.catch.hook (/Users/timoram/code/broken-project-test-cases/feathers-express-error/node_modules/@feathersjs/express/lib/rest/wrappers.js:79:46)\r\n    at <anonymous>\r\n    at process._tickCallback (internal/process/next_tick.js:188:7)\r\n```\r\n\r\n### System configuration\r\n\r\n**Module versions** :\r\n```shell\r\n$ npm list --depth=0\r\nfeathers-express-error@1.0.0 /Users/timoram/code/broken-project-test-cases/feathers-express-error\r\n├── @feathersjs/express@1.2.0\r\n└── @feathersjs/feathers@3.1.1\r\n```\r\n\r\n**NodeJS version**:\r\n```shell\r\n$ npm --version\r\n5.6.0\r\n$ node --version\r\nv8.9.4\r\n```\r\n\r\n**Operating System**:\r\n```shell\r\n$ sw_vers\r\nProductName:\tMac OS X\r\nProductVersion:\t10.12.5\r\nBuildVersion:\t16F73\r\n```\r\n\r\n**Browser Version**: N/A\r\n\r\n**React Native Version**: N/A\r\n\r\n**Module Loader**: N/A"}}
{"actor":{"display_login":"daffl"}}