Skip to content

Commit

Permalink
[issue-1568][bug]: make sure error object defined before access its m…
Browse files Browse the repository at this point in the history
…essage (#1569)
  • Loading branch information
reedfeng authored and aearly committed Aug 2, 2018
1 parent 3741f80 commit 5c174fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/asyncify.js
Expand Up @@ -87,7 +87,7 @@ function handlePromise(promise, callback) {
return promise.then(value => {
invokeCallback(callback, null, value);
}, err => {
invokeCallback(callback, err.message ? err : new Error(err));
invokeCallback(callback, err && err.message ? err : new Error(err));
});
}

Expand Down
13 changes: 13 additions & 0 deletions test/asyncify.js
Expand Up @@ -91,6 +91,19 @@ describe('asyncify', () => {
});
});

it('reject without reason', (done) => {
var promisified = function() {
return new Promise(((resolve, reject) => {
reject();
}));
};
async.asyncify(promisified)("argument", (err) => {
assert(err);
expect(err.message).to.eql('');
done();
});
});

it('callback error @nodeonly', (done) => {
expectUncaughtException();

Expand Down

0 comments on commit 5c174fa

Please sign in to comment.