redux-saga: weird error stack trace and error printing

Let say I throw an error in render() of React component, the console output is ok. But if i try console.log(this.a.b.c.d.e.f) instead, the console error message is sent by redux-saga to point out that the error is caused by the last saga even if that saga is well tested, and the stack trace is helpless as it just show the location of the log() utils func in redux-sage source code but not the wrong console.log(this.a.b.c.d.e.f)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

@yarcub

If what you need is crash reporting, you can attach an error handler to the root saga

sagaMiddleware.run(rootSaga).catch(...)

In the fiddle, the error is thrown while the Saga is executing a put Effect. Seems the dispatching is causing react-redux’s Connect to re-render the React Component. the Error is thrown from the Saga (because it was thrown in the same stack frame of yield put)

Like mentioned on #250, i’m also trying to send all uncaught exceptions to a monitoring system. The problem is when it happens on the same frame as a put effect. It would simply be logged by redux-saga and not reach the window.onerror handler.

@yelouafi, is there an option to disable this behavior and rethrow the exception? Does it makes sense?

@yarcub should be

sagaMiddleware.run(...).done.catch(...)

b/c run returns a Task object not a promise

I see, that’s right!

I’ve tried to replace result.message in previous code with result.stack and got: screen shot 2016-05-10 at 12 44 25 pm

which is fine for me. Is that a good fix for this?