Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saga with infinite loop should cancel on END action. #278

Closed
gugr opened this issue May 22, 2019 · 3 comments · Fixed by #377
Closed

Saga with infinite loop should cancel on END action. #278

gugr opened this issue May 22, 2019 · 3 comments · Fixed by #377
Labels

Comments

@gugr
Copy link

gugr commented May 22, 2019

Saga with infinite loop should cancel on END action.

@jp928
Copy link
Collaborator

jp928 commented Sep 6, 2019

@gugr
Do you mind to share a snippet to replicate this issue?

@jp928 jp928 added the bug label Sep 6, 2019
@vatosarmat
Copy link
Contributor

vatosarmat commented Nov 13, 2019

@jp928 it can be reproduces with such test

test('terminates on END action', async () => {
  warn.mockClear();

  function* infiniteLoop() {
    while (true) {
      // Redux-saga docs:
      // If you dispatch the END action, then all Sagas blocked on a take Effect
      // will be terminated regardless of the specified pattern
      yield take('HELLO_WORLD');
    }
  }

  await expectSaga(infiniteLoop)
    .dispatch(END)
    .run();

  expect(warn).not.toHaveBeenCalled(); //FAIL!
});

test('terminates on END action', async () => {
  warn.mockClear();

  function* infiniteLoop() {
    while (true) {
      yield take(END.type);
    }
  }

  await expectSaga(infiniteLoop)
    .dispatch(END)
    .run();

  expect(warn).not.toHaveBeenCalled(); //PASS
});

@vatosarmat
Copy link
Contributor

@jp928 it can be fixed with one-line change. Would you accept a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants