Giter Site home page Giter Site logo

Comments (9)

yelouafi avatar yelouafi commented on May 3, 2024 1

I'm thinking of making this an opt-in behavior. Provide some config argument, so the developer can choose to disable the console warnings

from redux-saga.

yelouafi avatar yelouafi commented on May 3, 2024

Not sure I understand the issue. Saga cancellation exceptions are only thrown when yielding a cancel effect. But I dont see any cancel effect in the code above

from redux-saga.

 avatar commented on May 3, 2024

Sorry, I left out an important piece - the root saga invoking this chain.

    function* root() {
        let process
        while (true) {
            yield take(SOME_TRIGGER)
            if (process && process.isRunning()) {
                yield cancel(process)
            }

            process = yield fork(fetchSomeStuff)
        }
    }

I use this pattern when the user can click on a list of items, and each click will trigger a data fetch for that item. If the user changes his mind and clicks on a different item while one is already loading, we can cancel the first data fetch.

It's not a huge ordeal, I'm just pointing out that when yield cancel(process) is triggered, it will throw SagaCancellationException in each branch of the fetchSomeStuff- which is fine, but it might be too ambitious to console.warn in each branch that doesn't explicitly handle that exception. I don't want to have to write a try/catch for every level of my saga if only one (bottom-most) or two (bottom most and top most) levels actually do anything after the exception.

from redux-saga.

yelouafi avatar yelouafi commented on May 3, 2024

but it might be too ambitious to console.warn in each branch that doesn't explicitly handle that exception

the warning is printed just to remind the developer in case he forgot to handle the cancellation. Which can lead to some mysterious bugs (inconsistent state)

from redux-saga.

 avatar commented on May 3, 2024

I would 👍 that... perhaps just the NODE_ENV="production" convention. I have used that with something like envify in the past and it works well.

from redux-saga.

yelouafi avatar yelouafi commented on May 3, 2024

perhaps just the NODE_ENV="production" convention. I have used that with something like envify in the past and it works well.

Agree; I think it's a better idea

from redux-saga.

gaearon avatar gaearon commented on May 3, 2024

Note that you'll want to make sure error behavior is exactly the same between prod and dev versions. If anything throws, it should throw in both cases. Logging a warning only in dev is fine though.

from redux-saga.

 avatar commented on May 3, 2024

Looks like this was taken care of in https://github.com/yelouafi/redux-saga/blob/no-promise/src/proc.js#L79-L81

from redux-saga.

yelouafi avatar yelouafi commented on May 3, 2024

@aft-luke yes. Included with the new 0.6.0

from redux-saga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.