diff --git a/lib/asyncify.js b/lib/asyncify.js index 168f88a20..24573771a 100644 --- a/lib/asyncify.js +++ b/lib/asyncify.js @@ -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)); }); } diff --git a/test/asyncify.js b/test/asyncify.js index 225f6d47b..f76c0a754 100644 --- a/test/asyncify.js +++ b/test/asyncify.js @@ -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();