Skip to content

Promise.join unhandled exceptions #373

@bjyoungblood

Description

@bjyoungblood

When using Promise.join, unhandled errors/exceptions result in an error message with no stack trace.

Adding a .catch and immediately re-throwing (as shown in the second case below) works as expected. Similarly, adding a Promise.onPossiblyUnhandledRejection handler also results in the correct error / stack trace.

The following code can be used to reproduce this:

var Promise = require('bluebird');
var fs      = require('fs');

Promise.promisifyAll(fs);

function rejectResult() {
  return fs.readFileAsync('no such file');
}

function goodResult() {
  return Promise.resolve('test');
}

Promise.all([ rejectResult(), goodResult() ]).then(function() {});
// Possibly unhandled Error: ENOENT, open 'no such file'

Promise.join(rejectResult(), goodResult(), function(file, val) {}).catch(function(err) {
  throw err;
});
// Possibly unhandled Error: ENOENT, open 'no such file'

Promise.join(rejectResult(), goodResult(), function(file, val) {});
// Possibly unhandled (<{"p5":null,"p4":null,"p3":null,"p2":"t...>, no stack trace)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions