{"action":"created","issue":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/695","labels_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/695/labels{/name}","comments_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/695/comments","events_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/695/events","html_url":"https://github.com/petkaantonov/bluebird/issues/695","id":93870955,"number":695,"title":"bluebird logs out \"unhandled rejection error\" despite rejection being handled by chai-as-promised","user":{"login":"keithamus","id":118266,"avatar_url":"https://avatars.githubusercontent.com/u/118266?v=3","gravatar_id":"","url":"https://api.github.com/users/keithamus","html_url":"https://github.com/keithamus","followers_url":"https://api.github.com/users/keithamus/followers","following_url":"https://api.github.com/users/keithamus/following{/other_user}","gists_url":"https://api.github.com/users/keithamus/gists{/gist_id}","starred_url":"https://api.github.com/users/keithamus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keithamus/subscriptions","organizations_url":"https://api.github.com/users/keithamus/orgs","repos_url":"https://api.github.com/users/keithamus/repos","events_url":"https://api.github.com/users/keithamus/events{/privacy}","received_events_url":"https://api.github.com/users/keithamus/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/petkaantonov/bluebird/labels/pending-author-input","name":"pending-author-input","color":"bfd4f2"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2015-07-08T19:31:45Z","updated_at":"2015-11-10T18:38:14Z","closed_at":"2015-07-10T12:35:06Z","body":"I'm moving this issue from domenic/chai-as-promised#97 - we have a user (@ohjames) who is claiming that while using bluebird, and asserting with chai-as-promised that rejection has been handled, bluebird still believes the rejection has not been handled. To quote the OP:\r\n\r\n> I would have thought this mocha test would work fine:\r\n> ```javascript\r\n  // Either I've made a mistake or chai-as-promised is crap...\r\n  it('finds that chai-as-promised is not broken', function() {\r\n    var Promise = require('bluebird')\r\n    var promise = Promise.reject(Error())\r\n    return promise.should.be.rejected\r\n  })\r\n```\r\n\r\n> It looks like it passes but check out the stderr after the test...\r\n\r\n> ```\r\n  User Model\r\n    ✓ finds that chai-as-promised is not broken \r\nUnhandled rejection Error\r\n    at Error (native)\r\n    at Context.<anonymous> (/home/mega-totoro/projects/cuddle-friends/server/api/user/user.model.spec.js:40:34)\r\n    at callFn (/home/mega-totoro/projects/cuddle-friends/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)\r\n    at Test.Runnable.run (/home/mega-totoro/projects/cuddle-friends/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)\r\n    at Runner.runTest (/home/mega-totoro/projects/cuddle-friends/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:374:10)\r\n    at /home/mega-totoro/projects/cuddle-friends/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:452:12\r\n    at next (/home/mega-totoro/projects/cuddle-friends/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:299:14)\r\n    at /home/mega-totoro/projects/cuddle-friends/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:309:7\r\n    at next (/home/mega-totoro/projects/cuddle-friends/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:247:23)\r\n```\r\n\r\n> Or am I doing something stupid?\r\n\r\n[here is the LOC where chai-as-promised handles the rejection](https://github.com/domenic/chai-as-promised/blob/master/lib/chai-as-promised.js#L130-L138)."},"comment":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/comments/155525504","html_url":"https://github.com/petkaantonov/bluebird/issues/695#issuecomment-155525504","issue_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/695","id":155525504,"user":{"login":"bergus","id":1146478,"avatar_url":"https://avatars.githubusercontent.com/u/1146478?v=3","gravatar_id":"","url":"https://api.github.com/users/bergus","html_url":"https://github.com/bergus","followers_url":"https://api.github.com/users/bergus/followers","following_url":"https://api.github.com/users/bergus/following{/other_user}","gists_url":"https://api.github.com/users/bergus/gists{/gist_id}","starred_url":"https://api.github.com/users/bergus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bergus/subscriptions","organizations_url":"https://api.github.com/users/bergus/orgs","repos_url":"https://api.github.com/users/bergus/repos","events_url":"https://api.github.com/users/bergus/events{/privacy}","received_events_url":"https://api.github.com/users/bergus/received_events","type":"User","site_admin":false},"created_at":"2015-11-10T18:38:14Z","updated_at":"2015-11-10T18:38:14Z","body":"I'd recommend to simply use\r\n```js\r\nvar p = new Promise( function(resolve,reject) {\r\n  // try-catch is unnecessary in the promise executor\r\n  console.log('code');\r\n  throw new Error('test');\r\n});\r\n\r\np.then(function() {\r\n  console.log('normal');\r\n}, function(reason) {\r\n  console.log('catch', reason);\r\n});\r\n```"}}