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

Comments

Projects
None yet
4 participants
@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

This comment has been minimized.

Show comment
Hide comment
@benjamingr

benjamingr Jun 7, 2015

Collaborator

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

Collaborator

benjamingr commented Jun 7, 2015

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

@tjconcept

This comment has been minimized.

Show comment
Hide comment
@tjconcept

tjconcept 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?

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

This comment has been minimized.

Show comment
Hide comment
@benjamingr

benjamingr Jun 7, 2015

Collaborator

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.

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@tjconcept

tjconcept 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)

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

This comment has been minimized.

Show comment
Hide comment
@spion

spion Jun 8, 2015

Collaborator

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

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@tjconcept

tjconcept 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 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

This comment has been minimized.

Show comment
Hide comment
@tjconcept

tjconcept 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.

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

This comment has been minimized.

Show comment
Hide comment
@petkaantonov

petkaantonov Jun 11, 2015

Owner

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

Owner

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

This comment has been minimized.

Show comment
Hide comment
@petkaantonov

petkaantonov Jun 14, 2015

Owner

Fixed in 2.9.28

Owner

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