Giter Club home page Giter Club logo

Comments (3)

domenic avatar domenic commented on June 9, 2024

This isn't really an appropriate repository for support questions like this. I'd try StackOverflow.

from promises-spec.

briancavalier avatar briancavalier commented on June 9, 2024

@kswope The spec is correct, and your second example is working as intended (although outside the scope of this spec). In the example, there is an unobserved rejected promise. Keeping in mind that p.then (and p.catch) doesn't modify the fulfill/reject state of p, but rather returns a new promise:

let p = Promise.reject( 'hi' )

// this line creates a new promise that is also rejected because p is rejected and
// the second argument to then() has been omitted.  The newly created, rejected
// promise is never assigned, and so *can never be handled*.  Thus, runtimes correctly
// report the unhandled rejection.
p.then( () => {} )

// This line creates a new promise that will always fulfill.  Because it handles p's
// error, runtimes use this as an indication that p's rejection is now handled.  This
// has no bearing on the rejected promise created by the line above.
p.catch( ( x ) => { console.log( x ) } )

Hope that helps.

from promises-spec.

kswope avatar kswope commented on June 9, 2024

Yes, thanks for the help. The problem I had was the 'forking' nature of promises and the fact that NOBODY mentions this.

Would you believe the next day somebody posted an elaborate slideshow on promises and made the exact same mistake!

I did some testing and it seems that only found bluebird and native promises will log a warning. I can imagine how much code out there using promises makes this same mistake. Its telling that warning are now issued from the two most popular libraries.

from promises-spec.

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.