{"action":"created","issue":{"url":"https://api.github.com/repos/reactjs/redux/issues/2173","repository_url":"https://api.github.com/repos/reactjs/redux","labels_url":"https://api.github.com/repos/reactjs/redux/issues/2173/labels{/name}","comments_url":"https://api.github.com/repos/reactjs/redux/issues/2173/comments","events_url":"https://api.github.com/repos/reactjs/redux/issues/2173/events","html_url":"https://github.com/reactjs/redux/issues/2173","id":198058562,"number":2173,"title":"Dispatch causes stop in code","user":{"login":"sam-n-johnston","id":17952091,"avatar_url":"https://avatars.githubusercontent.com/u/17952091?v=3","gravatar_id":"","url":"https://api.github.com/users/sam-n-johnston","html_url":"https://github.com/sam-n-johnston","followers_url":"https://api.github.com/users/sam-n-johnston/followers","following_url":"https://api.github.com/users/sam-n-johnston/following{/other_user}","gists_url":"https://api.github.com/users/sam-n-johnston/gists{/gist_id}","starred_url":"https://api.github.com/users/sam-n-johnston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sam-n-johnston/subscriptions","organizations_url":"https://api.github.com/users/sam-n-johnston/orgs","repos_url":"https://api.github.com/users/sam-n-johnston/repos","events_url":"https://api.github.com/users/sam-n-johnston/events{/privacy}","received_events_url":"https://api.github.com/users/sam-n-johnston/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-29T19:43:00Z","updated_at":"2016-12-29T19:48:57Z","closed_at":null,"body":"**Do you want to request a *feature* or report a *bug*?**  \r\n*bug*\r\n\r\n**What is the current behavior?**\r\n\r\nI dispatch a specific action and the rest of the function stops executing\r\n\r\n**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar.**\r\n\r\nI call my postResult function. The problem occurs during the second dispatch: \"second dispatched OK\" never gets printed to the console. If I replace the second dispatch with another type, rest of the function is executed correctly. \r\n \r\n```\r\nlet postResult = (tennisResultSet) => {\r\n  return (dispatch, getState) => {\r\n    return fetchWrapper('/api/results', 'POST', tennisResultSet.toJSObj())\r\n      .then((response) => {\r\n        let responseResultSet = makeResultFromResultSet(response).toJSObj()\r\n        dispatch({\r\n          payload: responseResultSet,\r\n          type: actionTypes.ADD_NEW_USERS_RESULT_TO_REDUX_STORE,\r\n        })\r\n        console.log('first dispatched OK')\r\n        dispatch({\r\n          payload: responseResultSet,\r\n          type: actionTypes.ADD_SINGLE_RESULT_TO_REDUX_STORE,\r\n        })\r\n        console.log('second dispatched OK')\r\n        Actions.popTo('root')\r\n        Actions.Feed()\r\n        dispatch(userActions.fetchAllOpponents(getState().currentUser.toJS()._id))\r\n      })\r\n  }\r\n}\r\n```\r\n\r\nHere is the reducer:\r\n```\r\nexport default (state = initialState, action = {}) => {\r\n  switch (action.type) {\r\n    case actionTypes.ADD_RESULTS_IN_REDUX_STORE:\r\n      return Immutable.fromJS(action.payload).concat(state)\r\n    case actionTypes.ADD_SINGLE_RESULT_TO_REDUX_STORE:\r\n      return Immutable.fromJS([action.payload]).concat(state)\r\n    default:\r\n      return state\r\n```\r\n\r\nIf I replace this part of the reducer, it starts working again:\r\n```\r\n    case actionTypes.ADD_SINGLE_RESULT_TO_REDUX_STORE:\r\n      return state\r\nOR\r\n    case actionTypes.ADD_SINGLE_RESULT_TO_REDUX_STORE:\r\n      return Immutable.List() // Empty list\r\n```\r\n\r\nEven when I try to dispatch this is does not work, the rest of the function is not executed\r\n```\r\n    case actionTypes.ADD_SINGLE_RESULT_TO_REDUX_STORE:\r\n      return { _id: 'test' } \r\n```\r\n\r\n**What is the expected behavior?**\r\n\r\nI expect the reducer to change the state and concatenate it with the new result. I have never had a problem similar to this in redux. I have tried to debug, but to no avail. The unit tests of these functions work perfectly (When I import the reducer and do tests directly on it). So I think there might be a problem elsewhere? The type `ADD_RESULTS_IN_REDUX_STORE` works perfectly, even if I send it multiple actions when the app loads, but if I change this: \r\n```\r\n        dispatch({\r\n          payload: responseResultSet,\r\n          type: actionTypes.ADD_SINGLE_RESULT_TO_REDUX_STORE,\r\n        })\r\n``` \r\nto this:\r\n```\r\n        dispatch({\r\n          payload: [responseResultSet],\r\n          type: actionTypes.ADD_RESULTS_IN_REDUX_STORE,\r\n        })\r\n```\r\nit still doesn't work. \r\n\r\n**Which versions of Redux, and which browser and OS are affected by this issue? Did this work in previous versions of Redux?**\r\n\r\nI'm using redux 3.6.0 and redux-thunk 2.1.0\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/reactjs/redux/issues/comments/269683447","html_url":"https://github.com/reactjs/redux/issues/2173#issuecomment-269683447","issue_url":"https://api.github.com/repos/reactjs/redux/issues/2173","id":269683447,"user":{"login":"markerikson","id":1128784,"avatar_url":"https://avatars.githubusercontent.com/u/1128784?v=3","gravatar_id":"","url":"https://api.github.com/users/markerikson","html_url":"https://github.com/markerikson","followers_url":"https://api.github.com/users/markerikson/followers","following_url":"https://api.github.com/users/markerikson/following{/other_user}","gists_url":"https://api.github.com/users/markerikson/gists{/gist_id}","starred_url":"https://api.github.com/users/markerikson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markerikson/subscriptions","organizations_url":"https://api.github.com/users/markerikson/orgs","repos_url":"https://api.github.com/users/markerikson/repos","events_url":"https://api.github.com/users/markerikson/events{/privacy}","received_events_url":"https://api.github.com/users/markerikson/received_events","type":"User","site_admin":false},"created_at":"2016-12-29T19:48:57Z","updated_at":"2016-12-29T19:48:57Z","body":"That's... both a good amount of information, and not enough.\r\n\r\nAre there any error messages logged in the console?  What happens if you put a breakpoint on that reducer line and step past there?\r\n\r\nIt's highly unlikely that this is an issue with Redux itself.  That said, if you can create a repo that demonstrates this issue, it might be possible to take a look at it."}}
{"actor":{"display_login":"markerikson"}}