Giter VIP home page Giter VIP logo

futurejs's People

Contributors

bobwall23 avatar cjyar avatar dependabot[bot] avatar ernieturner avatar giarc3 avatar leeroy-travis avatar skeet70 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

brugarolas

futurejs's Issues

Fix vulnerability

GitHub is reporting a high severity vulnerability CVE2019-10747 in set-value.

Add ability to define custom error type

By default, our Future library exists errors to be Error instances. In a number of places we use our own custom error type, so we should allow users to define this custom error type as part of the Future constructor.

Upgrade handlebars, js-yaml

Known high severity security vulnerability detected in handlebars < 4.0.14 defined in yarn.lock.

yarn.lock update suggested: handlebars ~> 4.0.14.

Known high severity security vulnerability detected in js-yaml < 3.13.1 defined in yarn.lock.

yarn.lock update suggested: js-yaml ~> 3.13.1.

`handleWith` causes Future chain to be called twice if `engage` `resolve` fails.

This is pretty edge case and strange behavior. This was discovered while using the library where the Future in question changed test state. When an assertion in the .engage on that future failed, it caused the handleWith code of the already engaged Future to be called again, which cause the map to be called again, which then blew up because the state had already changed. I pushed a minimal reproduction of the bug on the branch handle-called-out-of-scope.

test("does not get run if engages above this scope throw", (done) => {
            let mapCalledTimes = 0;
            let handleWithCalledTimes = 0;
            const action = Future.of(33)
                .handleWith((e) => {
                    console.log(`failed an infallible future: ${e}`);
                    handleWithCalledTimes++;
                    return Future.of(-1);
                })
                .map((r) => {
                    mapCalledTimes++;
                    return r;
                });

            try {
                action.engage(
                    (e) => {
                        throw e;
                    },
                    (r) => {
                        throw new Error(`oh no, something went wrong after the future has run to completion on ${r}`);
                    }
                );
            } catch (e) {
                expect(handleWithCalledTimes).toBe(0);
                expect(mapCalledTimes).toBe(1);
                done();
            }
        });

That's the test entirely though. The error thrown in the .engage causes the whole chain of the Future the engage was called on to run when it's somehow caught by the handleWith. The same thing happens if you start with a rejected Future, though then everything in the chain is run twice including the handleWith.

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.