Skip to content
This repository has been archived by the owner on Mar 22, 2020. It is now read-only.

Fixing "Cannot read property cancel of undefined" #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/utils/sagaInjectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function ejectSagaFactory(store, isValid) {

if (Reflect.has(store.injectedSagas, key)) {
const descriptor = store.injectedSagas[key];
if (descriptor.mode !== DAEMON) {
if (descriptor.mode && descriptor.mode !== DAEMON) {
descriptor.task.cancel();
// Clean up in production; in development we need `descriptor.saga` for hot reloading
if (process.env.NODE_ENV === 'production') {
Expand Down
4 changes: 2 additions & 2 deletions app/utils/tests/sagaInjectors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ describe('injectors', () => {
expect(() => ejectSaga(1)).toThrow();
});

it('should cancel a saga in a default mode', () => {
it('should cancel a saga in RESTART_ON_REMOUNT mode', () => {
const cancel = jest.fn();
store.injectedSagas.test = { task: { cancel } };
store.injectedSagas.test = { task: { cancel }, mode: RESTART_ON_REMOUNT };
ejectSaga('test');

expect(cancel).toHaveBeenCalled();
Expand Down