Permalink
Browse files

fix(errors): errors from reducers are no longer caught and logged, in…

…stead are rethrown. related #263#issuecomment-395109222

BREAKING CHANGE: For 0.19.0 errors from reducers are no longer caught and console.error logged, instead they are just rethrown as before. This was a temporary workaround for a bug in rxjs where it would silently swallow errors. That bug has been fixed in 5.5.6+, so it is highly recommended you use _at least_ rxjs@5.5.6+ with this version of redux-observable. However, redux-observable is close to reaching 1.0.0-final which will require rxjs v6 and redux v4, if you'd like to start upgrading to it now you can use redux-observable@next (as of this writing 1.0.0-beta.1)
  • Loading branch information...
jayphelps committed Jun 6, 2018
1 parent f632eaa commit f90f8ef233a3465ac3985c32d981f93448f8eec3
Showing with 6 additions and 14 deletions.
  1. +1 −7 src/createEpicMiddleware.js
  2. +5 −7 test/createEpicMiddleware-spec.js
@@ -53,13 +53,7 @@ export function createEpicMiddleware(rootEpic, options = defaultOptions) {
return output$;
})
::switchMap(output$ => options.adapter.output(output$))
.subscribe(action => {
try {
store.dispatch(action);
} catch (err) {
console.error(err);
}
});
.subscribe(store.dispatch);
// Setup initial root epic
epic$.next(rootEpic);
@@ -70,13 +70,11 @@ describe('createEpicMiddleware', () => {
]);
});
it('should console error when reducer throw exception', () => {
sinon.spy(console, 'error');
it('should rethrow errors when a reducer throws an exception', () => {
const reducer = (state = [], action) => {
switch (action.type) {
case 'ACTION_1':
throw new Error();
throw new Error('bad stuff');
default:
return state;
}
@@ -89,9 +87,9 @@ describe('createEpicMiddleware', () => {
const middleware = createEpicMiddleware(epic);
const store = createStore(reducer, applyMiddleware(middleware));
store.dispatch({ type: 'FIRE_1' });
expect(console.error.callCount).to.equal(1);
console.error.restore();
expect(() => {
store.dispatch({ type: 'FIRE_1' });
}).to.throw(Error, 'bad stuff');
});
it("should throw if you don't provide a rootEpic", () => {

0 comments on commit f90f8ef

Please sign in to comment.