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

Error: fork: argument fn is undefined or null #10086

Closed
sahlouls opened this issue Jun 12, 2019 · 6 comments

Comments

Projects
None yet
4 participants
@sahlouls
Copy link

commented Jun 12, 2019

Bug Report

Current Behavior
When running test with Jest, despite all tests are successful, I still have a console error

 console.error node_modules/@redux-saga/core/dist/chunk-774a4f38.js:104
      Error: fork: argument fn is undefined or null
          at check (/home/dsdsd/repos/ggg-gui/node_modules/@redux-saga/core/dist/chunk-774a4f38.js:26:11)
          at validateFnDescriptor (/home/dsdsd/repos/ggg-gui/node_modules/@redux-saga/core/dist/chunk-774a4f38.js:446:3)
          at fork (/home/dsdsd/repos/ggg-gui/node_modules/@redux-saga/core/dist/chunk-774a4f38.js:546:5)

my root saga

export default function* rootSaga(): SagaIterator {
  yield all([
    fork(mySaga1),
    fork(mySaga2),
    fork(mySaga3),
  ]);
}

The issue appear only when I added the mySaga3.

All is working perfectly, just this console error.

Any idea where this error is coming from ? how to fix it ?

@babel-bot

This comment has been minimized.

Copy link
Collaborator

commented Jun 12, 2019

Hey @sahlouls! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

commented Jun 12, 2019

How is this related to Babel?
I suggest adding some console.logs to understand what is undefined and why.

@sahlouls sahlouls closed this Jun 12, 2019

@sahlouls

This comment has been minimized.

Copy link
Author

commented Jun 12, 2019

It was related to redux saga. Solved

@avilde

This comment has been minimized.

Copy link

commented Jun 12, 2019

Hi, @sahlouls .
I have the exact same problem. How did you solved it?

@sahlouls

This comment has been minimized.

Copy link
Author

commented Jun 12, 2019

Hi @avilde

Two workarounds worked for me, I choose the 1st

  • Import the store where the sagaRoot is running in the test file
  • do not run the sagaRoot when running tests
if (process.env.NODE_ENV !== 'test') {
  sagaMiddleware.run(rootSaga);
}
@avilde

This comment has been minimized.

Copy link

commented Jun 13, 2019

@sahlouls , I debugged the code and in the end I could not find the reason why one of my sagas is undefined for no reason.

In the end I rewrote my root saga generator:

function* rootSaga() {
  const sagas = [sagaOne, sagaTwo, sagaThree].filter(
    saga => saga !== undefined
  );

  yield all(sagas.map(saga => fork(saga)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.