Comments (3)
This isn't really an appropriate repository for support questions like this. I'd try StackOverflow.
from promises-spec.
@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.
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)
- Can you assist me in satisfying promises aplus spec 2.2.4 in NodeJS? HOT 4
- here is a Chinese translation HOT 1
- Confused terminology: resolve and fulfill HOT 3
- Proposal: Make clear in the spec that the Promise constructor runs the provided function body immediately HOT 1
- Relationship with ECMA-262 ยง 25.4.2 - Promise Jobs HOT 4
- What is the intention behind clause 2.2.4 of Promise/A+ spec? HOT 5
- change "if x is a promise" to something non-circular and clear HOT 7
- clarify "is an object or function" HOT 10
- Clarify ambiguity between promises and thenables w.r.t. 2.3.2.1? HOT 5
- Promise Resolution Procedure 3.iii: What if then never calls its arguments? HOT 2
- Some imprecise points in this spec HOT 22
- Question about **promise resolution procedure** 2.3.2 HOT 2
- Adopting state without .then() HOT 2
- Support translation
- What happened? please see code
- please see code HOT 1
- Rust promise implementation
- Add my implementation of promises
- Confused about the point of 2.3.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from promises-spec.