{"action":"created","issue":{"url":"https://api.github.com/repos/mzabriskie/axios/issues/215","labels_url":"https://api.github.com/repos/mzabriskie/axios/issues/215/labels{/name}","comments_url":"https://api.github.com/repos/mzabriskie/axios/issues/215/comments","events_url":"https://api.github.com/repos/mzabriskie/axios/issues/215/events","html_url":"https://github.com/mzabriskie/axios/issues/215","id":129697600,"number":215,"title":"Axios interceptors are causing unhandled promise rejections","user":{"login":"vjpr","id":281413,"avatar_url":"https://avatars.githubusercontent.com/u/281413?v=3","gravatar_id":"","url":"https://api.github.com/users/vjpr","html_url":"https://github.com/vjpr","followers_url":"https://api.github.com/users/vjpr/followers","following_url":"https://api.github.com/users/vjpr/following{/other_user}","gists_url":"https://api.github.com/users/vjpr/gists{/gist_id}","starred_url":"https://api.github.com/users/vjpr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vjpr/subscriptions","organizations_url":"https://api.github.com/users/vjpr/orgs","repos_url":"https://api.github.com/users/vjpr/repos","events_url":"https://api.github.com/users/vjpr/events{/privacy}","received_events_url":"https://api.github.com/users/vjpr/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-29T08:06:35Z","updated_at":"2016-01-29T08:37:04Z","closed_at":"2016-01-29T08:37:04Z","body":"When a promise is rejected, even if it has a rejection handler I am seeing this message:\r\n\r\n```\r\nUncaught (in promise): { <error> }\r\n```\r\n\r\n~~When I comment out the interceptor middleware the unhandled rejections do not occur anymore.~~\r\n\r\nhttps://github.com/mzabriskie/axios/blob/70ef49eeb93b7cdc0e3579a263268ffd64cfa108/lib/axios.js#L72-L74\r\n```\r\n  //while (chain.length) {\r\n  //  promise = promise.then(chain.shift(), chain.shift());\r\n  //}\r\n```\r\n\r\nMy code looks like this:\r\n\r\n```\r\nexport const promiseMiddleware = store => next => action => {\r\n\r\n  const { promise, types, ...rest } = action\r\n\r\n  if (!promise) {\r\n    return next(action)\r\n  }\r\n\r\n  const [REQUEST, SUCCESS, FAILURE] = types\r\n  next({...rest, type: REQUEST})\r\n  return promise.then(\r\n    (result) => next({...rest, result, type: SUCCESS}),\r\n    (error) => {next({...rest, error, type: FAILURE})}\r\n  )\r\n\r\n}\r\n```\r\n\r\nIf I add a `catch` it fixes it too:-\r\n\r\n```\r\n  while (chain.length) {\r\n    promise = promise.then(chain.shift(), chain.shift()).catch(function() {console.log(arguments)});\r\n  }\r\n```\r\n\r\n**EDIT**\r\n\r\nMy requests were not actually firing anymore when I commented it out which is why the error didn't occur. But placing a catch prevents the unhandled rejections still."},"comment":{"url":"https://api.github.com/repos/mzabriskie/axios/issues/comments/176641327","html_url":"https://github.com/mzabriskie/axios/issues/215#issuecomment-176641327","issue_url":"https://api.github.com/repos/mzabriskie/axios/issues/215","id":176641327,"user":{"login":"vjpr","id":281413,"avatar_url":"https://avatars.githubusercontent.com/u/281413?v=3","gravatar_id":"","url":"https://api.github.com/users/vjpr","html_url":"https://github.com/vjpr","followers_url":"https://api.github.com/users/vjpr/followers","following_url":"https://api.github.com/users/vjpr/following{/other_user}","gists_url":"https://api.github.com/users/vjpr/gists{/gist_id}","starred_url":"https://api.github.com/users/vjpr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vjpr/subscriptions","organizations_url":"https://api.github.com/users/vjpr/orgs","repos_url":"https://api.github.com/users/vjpr/repos","events_url":"https://api.github.com/users/vjpr/events{/privacy}","received_events_url":"https://api.github.com/users/vjpr/received_events","type":"User","site_admin":false},"created_at":"2016-01-29T08:37:04Z","updated_at":"2016-01-29T08:37:04Z","body":"False alarm!\r\n\r\nIn my console I was seeing two 401s for two different endpoints.\r\n\r\nHowever, one endpoint was working perfectly, the other was being invoked twice and producing two unhandled rejections. Such is life."}}