question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using takeEvery from redux-saga/effects causes TypeError: Cannot read property 'next' of undefined

See original GitHub issue

In the latest version of redux saga (^0.16.0) I was getting a console warning about how importing takeEvery from redux-saga was deprecated and that it needed to be from redux-saga/effects.

Doing so seems to have broken rstp, and now I get the following error:

console.error node_modules/redux-saga/lib/internal/utils.js:240
      uncaught at tokenSaga at tokenSaga
       at takeEvery
       TypeError: Cannot read property 'next' of undefinedat sagaWrapper ([...]redux-saga-test-plan/lib/expectSaga/sagaWrapper.js:54:34)

switching back to the root takeEvery import works without a problem. Also worth noting that the sagas work fine outside of the test scenario.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
alisa-medvedevacommented, Mar 1, 2022

@jfairbank Addition: if called function in effect ‘fork’ has one argument await expectSaga(myExampleSaga) .provide({ fork: effect => effect.fn(effect.args[0]), }) .run();

if called function in effect ‘fork’ has two arguments await expectSaga(myExampleSaga) .provide({ fork: effect => effect.fn(effect.args[0], effect.args[1]), }) .run();

etc

0reactions
alisa-medvedevacommented, Mar 1, 2022

@jfairbank When I was testing sagas with effect “fork”, I have errors like:

  1. ‘Cannot read property ‘next’ of undefined’
  2. ‘Cannot read property ‘apply’ of undefined’

And I guess that all this errors exist, because ‘redux-saga-test-plan’ calls function in effect ‘fork’ incorrectly. I solved this problem with

await expectSaga(myExampleSaga) .provide({ fork: effect => effect.fn(effect.args[0]), }) .run();

        If I use this way, 'redux-saga-test-plan' calls function in effect 'fork' correctly. 
        
        If I don't want 'redux-saga-test-plan' calls function in effect 'fork', I use this second way (see below):
        
        `  await expectSaga(myExampleSaga)
        .provide({
            fork: (effect, next) => next,
        })`
        
        my package.json: 
        "redux-saga-test-plan": "4.0.0-rc.3",
        "redux-saga": "^1.1.3",
        
        Thank you for your wonderful library)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Redux-Saga: TypeError: Cannot read properties of undefined ...
I am not sure what's causing this error, but even the logger of my app doesn't even show the actions being dispatched. Any...
Read more >
A brand new website interface for an even better experience!
Using takeEvery from redux-saga/effects causes TypeError: Cannot read property 'next' of undefined.
Read more >
How to Avoid the Infamous "Cannot read properties of ... - Bitovi
With TypeScript, there are two ways of interpreting null and undefined ... avoid the 'Cannot read properties of undefined' runtime TypeError.
Read more >
yelouafi/redux-saga - Gitter
Uncaught (in promise) TypeError: Cannot read property 'sagaStack' of undefined ... a single saga using redux-saga/effects/fork and redux-saga/effects/all .
Read more >
API Reference - Redux-Saga
If take is called with no arguments or '*' all dispatched actions are matched (e.g. take() will match all ... import { takeEvery...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found