{"action":"created","issue":{"url":"https://api.github.com/repos/cisco/node-jose/issues/79","repository_url":"https://api.github.com/repos/cisco/node-jose","labels_url":"https://api.github.com/repos/cisco/node-jose/issues/79/labels{/name}","comments_url":"https://api.github.com/repos/cisco/node-jose/issues/79/comments","events_url":"https://api.github.com/repos/cisco/node-jose/issues/79/events","html_url":"https://github.com/cisco/node-jose/issues/79","id":195783261,"number":79,"title":"UnhandledPromiseRejectionWarning","user":{"login":"4poc","id":168797,"avatar_url":"https://avatars.githubusercontent.com/u/168797?v=3","gravatar_id":"","url":"https://api.github.com/users/4poc","html_url":"https://github.com/4poc","followers_url":"https://api.github.com/users/4poc/followers","following_url":"https://api.github.com/users/4poc/following{/other_user}","gists_url":"https://api.github.com/users/4poc/gists{/gist_id}","starred_url":"https://api.github.com/users/4poc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4poc/subscriptions","organizations_url":"https://api.github.com/users/4poc/orgs","repos_url":"https://api.github.com/users/4poc/repos","events_url":"https://api.github.com/users/4poc/events{/privacy}","received_events_url":"https://api.github.com/users/4poc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-15T11:34:46Z","updated_at":"2016-12-15T12:22:28Z","closed_at":null,"body":"Node Version: v6.6.0\r\nnode-jose: 0.9.1\r\n\r\nI have trouble handling malformed data errors with JWE decryption.\r\n\r\nExample Code:\r\n```\r\nconst jose = require('node-jose');\r\n\r\nconst keystore = jose.JWK.createKeyStore();\r\n\r\nkeystore.generate('oct', 256).\r\n    then(() => {\r\n\r\n        jose.JWE.createDecrypt(keystore).decrypt('asdf').\r\n        then((result) => {\r\n            console.log('Result: ', result);\r\n        }).\r\n        catch((err) => {\r\n            console.log('Handled error (decrypt)', err);\r\n        });\r\n\r\n    }).\r\n    catch((err) => {\r\n        console.log('Handled error (keystore generate)', err);\r\n    });\r\n```\r\n\r\nThis prints:\r\n\r\n```\r\nHandled error (decrypt) Error: no key found\r\n    at processKey (/home/apoc/projects/ms/frontend/node_modules/node-jose/lib/jwe/decrypt.js:157:22)\r\n    at process._tickCallback (internal/process/next_tick.js:103:7)\r\n    at Module.runMain (module.js:592:11)\r\n    at run (bootstrap_node.js:394:7)\r\n    at startup (bootstrap_node.js:149:9)\r\n    at bootstrap_node.js:509:3\r\n(node:3169) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token j in JSON at position 0\r\n```\r\n\r\nI can't figure out why this triggers a UnhandledPromiseRejectionWarning? The returned promise should already be rejected at the `JSON.parse`."},"comment":{"url":"https://api.github.com/repos/cisco/node-jose/issues/comments/267315208","html_url":"https://github.com/cisco/node-jose/issues/79#issuecomment-267315208","issue_url":"https://api.github.com/repos/cisco/node-jose/issues/79","id":267315208,"user":{"login":"4poc","id":168797,"avatar_url":"https://avatars.githubusercontent.com/u/168797?v=3","gravatar_id":"","url":"https://api.github.com/users/4poc","html_url":"https://github.com/4poc","followers_url":"https://api.github.com/users/4poc/followers","following_url":"https://api.github.com/users/4poc/following{/other_user}","gists_url":"https://api.github.com/users/4poc/gists{/gist_id}","starred_url":"https://api.github.com/users/4poc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4poc/subscriptions","organizations_url":"https://api.github.com/users/4poc/orgs","repos_url":"https://api.github.com/users/4poc/repos","events_url":"https://api.github.com/users/4poc/events{/privacy}","received_events_url":"https://api.github.com/users/4poc/received_events","type":"User","site_admin":false},"created_at":"2016-12-15T12:22:28Z","updated_at":"2016-12-15T12:22:28Z","body":"seems node related, I don't get the warning with node v4.6.2"}}
{"actor":{"display_login":"4poc"}}