redux-saga: console.error: "uncaught", "at rootSaga at loginFlow ...
I’m trying to implement a really basic login skeleton similar to what is detailed in the docs. Mine is a little simpler since in my UI there will be no way for the user to send a login action before the login actually occurs. But, I am working in react-native if that makes any difference.
So I have a button right now that dispatches an action with a mock payload. This action is recognized by the reducer, so it is firing. But when it hits the saga for some reason I get the following error:

Here is my saga code:
function* authorize(email, password) {
// just returns a fake token for now
const session = 'fake'
yield console.log('in authorize');
yield put({type: types.LOGIN_SUCCESS, session});
return session;
}
function* loginFlow() {
while (true) {
const submit_action = yield take(types.LOGIN_SUBMITTED);
const email = submit_action.payload.email;
const password = submit_action.payload.password;
yield console.log(email);
const session = yield call(authorize, email, password);
// After we're logged in, only thing we can do is log out
// TODO: figure out what to actually do here?
if (session) {
yield take('LOGOUT')
}
}
}
export default function* rootSaga() {
yield fork(loginFlow);
}
Also, here is my saga initialization code:
// saga initialization
const sagaMiddleware = createSagaMiddleware();
const store = applyMiddleware(sagaMiddleware)(createStore)(reducer);
sagaMiddleware.run(rootSaga).done.catch((error) => console.warn(error));
The exception seems to occur before the console.log(email) in loginFlow. I’m not really sure how this is happening. Any help on the issue would be appreciated.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 22 (10 by maintainers)
Is there any way to make these exception errors more helpful? It doesn’t matter what kind of exception is raised, but every kind of error looks exactly like OPs screenshot. There is no way to see where the error originates from. I’m using
redux-sagain a React Native context.Probably one of your dispatched actions
throw, one ofloginSuccess,loginFailure.It may be in you reducer, I see there is a
replaceAtIndexfunction in your call stack. Maybe it doesnt receive correct arguments? Try to wrap your actions in:and your should find the mistake within minutes.
Hope you catch it!
@AlastairTaft
This should no longer be the case with latest beta release.
I found a better way than my
try/catcheverywhere. I forked redux-saga and changed this:https://github.com/redux-saga/redux-saga/blob/v0.14.3/src/internal/proc.js#L437by basically loggingerror.messageon its own one line before. This way I get the stack AND the error message on an uncaught exception. I’d be happy to make a PR but I pretty much know nothing aboutnpmand compiling the library with those simple changes modifies a lot the files under thedistfolder, which doesn’t sound right.@Baisang : Do you remember what caused the issue? I’m facing the same problem Best, D