Skip to content

Unhandled rejection when joining chains with common rejected parent #645

Closed

Description

@tjconcept

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?

Activity

  1. benjamingr commented on Jun 7, 2015

    @benjamingr
    Collaborator

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

  2. tjconcept commented on Jun 7, 2015

    @tjconcept
    Author

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

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

  3. benjamingr commented on Jun 7, 2015

    @benjamingr
    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.

  4. tjconcept commented on Jun 7, 2015

    @tjconcept
    Author

    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)
  5. spion commented on Jun 8, 2015

    @spion
    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

  6. tjconcept commented on Jun 9, 2015

    @tjconcept
    Author

    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.

  7. tjconcept commented on Jun 10, 2015

    @tjconcept
    Author

    You can always use Promise.all

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

  8. petkaantonov commented on Jun 11, 2015

    @petkaantonov
    Owner

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

  9. petkaantonov commented on Jun 14, 2015

    @petkaantonov
    Owner

    Fixed in 2.9.28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions