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 is not removed #137

Open
hwzhang92 opened this issue Mar 2, 2020 · 3 comments
Open

Saga is not removed #137

hwzhang92 opened this issue Mar 2, 2020 · 3 comments

Comments

@hwzhang92
Copy link

hwzhang92 commented Mar 2, 2020

when use redux-dynamic-modules-saga, it dont remove saga when use DynamicModuleLoader or remove handle returned by store.addModules. When it add module again, the saga will also be two.

@abettadapur
Copy link
Collaborator

Are you using <StrictMode> any where in your React application?

@dmitry-prohorov
Copy link

@abettadapur I've faced the same issue.

Saga with spawn does it.

function* rootSaga() {
  yield all([fork(someSaga1), spawn(someSaga2)])
}

also example from saga documentations

function* rootSaga () {
  const sagas = [
    saga1,
    saga2,
    saga3,
  ];

  yield all(sagas.map(saga =>
    spawn(function* () {
      while (true) {
        try {
          yield call(saga)
          break
        } catch (e) {
          console.log(e)
        }
      }
    }))
  );
}

Any ideas on how to solve it? I don't think there is any.

@abettadapur
Copy link
Collaborator

spawn creates a saga at the root level, so it is not something we can cancel

If you use spawn, make sure to save a reference to the task so you can manually cancel it

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

No branches or pull requests

3 participants