question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

console.error: "uncaught", "at rootSaga at loginFlow ...

See original GitHub issue

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:

screen shot 2016-06-14 at 5 20 40 pm

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:closed
  • Created 7 years ago
  • Comments:22 (10 by maintainers)

github_iconTop GitHub Comments

68reactions
rclaicommented, Oct 13, 2016

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.

11reactions
Andaristcommented, Dec 23, 2016

Probably one of your dispatched actions throw, one of loginSuccess, 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:

try {
  // ... regular action code
} catch (e) {
  debugger
}

and your should find the mistake within minutes.

Hope you catch it!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found