console.error: "uncaught", "at rootSaga at loginFlow ...
See original GitHub issueI’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.
Issue Analytics
- State:
- Created 7 years ago
- Comments:22 (10 by maintainers)
Top Results From Across the Web
react native - uncaught at rootSaga at ... - Stack Overflow
In the above line 'error' is not defined hence the error occurs. You can change this line to something like below: yield put({...
Read more >redux-saga.cancelled JavaScript and Node.js code examples
export default function* rootSaga() { try { yield fork(runProcesses); } catch (e) { console.error('[root-saga]: An Uncaught Error Occurred: ', e.message); } ...
Read more >Root Saga
Uncaught errors from forked tasks bubble to the parent task and thus abort it (and all its child tasks) - they cannot be...
Read more >Redux-Saga - Cacher Snippet
Sada moramo da pozovemo sagaMiddleware.run() na root Saga u main.js ... Cim se pojavi uncaught error od jednog od svojih attached forks.
Read more >Can't figure redux-logger console error on ZTM Reacte ...
Can't figure redux-logger console error on ZTM Reacte-commerce course project ... Uncaught (in promise) TypeError: Cannot read properties of ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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-saga
in 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
replaceAtIndex
function 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!