I'm combining a set of Sagas, ( some takeEvery
and takeLatest
) from different modules and using yield all(sagas)
to combine them all in RootSaga.
Everything works, without issue. I catch errors inside the Sagas themselves. But, now the requirement is to catch errors at RootSaga level too, in any case, someone misses catching a problematic part.( Actually, I'm working on boilerplate for a multi-team project. )
I see, if someone is not using try catch to catch a problematic part, then the error is propagated and Saga completely stops working after that. Sagas won't watch anything thereafter.
What I want to do is, let other Sagas run without issues and RootSaga to be working thereafter, keep watching as usual. How can I achieve this?
export default function* rootSaga() {
yield all(sagas);
}
For v1 use
rootSagaTask.toPromise().catch(e => {
});
When you run the rootSaga
you are getting back a task. That task has a done
property which is a promise. So:
const rootSagaTask = reduxSagaMiddleware.run(rootSaga);
rootSagaTask.done.catch(error => {
// Error here is a fatal error.
// None of the sagas down the road caught it.
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With