Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled rejection when joining chains with common rejected parent #645

Closed
tjconcept opened this issue Jun 7, 2015 · 9 comments
Closed

Unhandled rejection when joining chains with common rejected parent #645

tjconcept opened this issue Jun 7, 2015 · 9 comments
Labels

Comments

@tjconcept
Copy link

@tjconcept tjconcept commented Jun 7, 2015

Maybe I should do this kind of stuff in another way, but I've hit it a couple of times now and it's extremely hard to debug and, at least in my head, seems inconsistent and unintuitive.

var Promise = require('bluebird');

var a = Promise.try(function(){
    throw new Error('Something went wrong');
});

var b = Promise.try(function(){
    throw new Error('Something went wrong here as well');
});

var c = Promise
    .join(a, b)
    .spread(function( a, b ){
        return a+b;
    });

Promise
    .join(a, c)
    .spread(function( a, product ){
        // ...
    })
    .catch(Error, function(e){
        console.log(e);
    });

The workaround is to "silent" the a-chain in the last join with .catch(noop) (#483 in the future), but then c needs to know about the fact that a is part of c which is not always easy.

Does it make sense?

@benjamingr
Copy link
Collaborator

@benjamingr benjamingr commented Jun 7, 2015

Can you check if this happens with the correct .join syntax?

@tjconcept
Copy link
Author

@tjconcept tjconcept commented Jun 7, 2015

It does not happen with join(a, c, fn), if that is what you mean?

I was not aware this was incorrect.. How come?

@benjamingr
Copy link
Collaborator

@benjamingr benjamingr commented Jun 7, 2015

The old join syntax was deprecated and then superseded with the (a, b, fn) one a while ago.

That said, the face of still works (the old syntax) means that either:

  • the behavior in terms of unhandled rejection tracking should be fixed
  • 3.0 should remove it and give a big fat warning

Either is fine by me - the current behavior isn't good.

@tjconcept
Copy link
Author

@tjconcept tjconcept commented Jun 7, 2015

What were the reasons for deprecating the "old" syntax? I think it aligns nicely with .all, .props and so forth. How is it different?

How would I do something like this with the "new" syntax:

Promise.join(a, b).bind(console).spread(console.log)
@spion
Copy link
Collaborator

@spion spion commented Jun 8, 2015

You can always use Promise.all

Promise.all([a,b]).bind(console).spread(console.log)

though when I proposed the original change for join I didn't really mean to suggest deprecating the old one - its just that it was much easier to model the type signatures in TypeScript for the new syntax

@tjconcept
Copy link
Author

@tjconcept tjconcept commented Jun 9, 2015

Hmm.. I really think of join and spread as two different things, just as resolve and then.
spread is calling the function with .apply or using the spread operator from ES6, regardless of the actual resolved value.
join is combining several values into an array of resolved values - like using rest parameters.

@tjconcept
Copy link
Author

@tjconcept tjconcept commented Jun 10, 2015

You can always use Promise.all

Seems like .all is giving me the same behaviour as .join().spread() with an uncaught exception.

@petkaantonov
Copy link
Owner

@petkaantonov petkaantonov commented Jun 11, 2015

Yea it's a bug that I fixed a while ago in 3.0 with b182d5b . Maybe it could be backported

@petkaantonov
Copy link
Owner

@petkaantonov petkaantonov commented Jun 14, 2015

Fixed in 2.9.28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.