dfilatov / vow

ES6-compatible and Promises/A+ implementation for Node.js and browsers
MIT License
344 stars 45 forks source link

Error in executor function doesn't reject promise #114

Closed ikokostya closed 7 years ago

ikokostya commented 7 years ago

From MDN

If an error is thrown in the executor function, the promise is rejected.

Native promise

Code

'use strict';

const p = new Promise(() => {
    throw new Error('boom');
});

p.catch(err => console.log(`catch ${err}`));

Result

$ node t.js
catch Error: boom

vow.Promise

Code

'use strict';

const vow = require('vow');

const p = new vow.Promise(() => {
    throw new Error('boom');
});

p.catch(err => console.log(`catch ${err}`));

Result

$ node t.js 
/home/kostya/tmp/pg-test/t.js:6
    throw new Error('boom');
    ^

Error: boom
    at vow.Promise (/home/kostya/tmp/pg-test/t.js:6:11)
    at Promise (/home/kostya/node_modules/vow/lib/vow.js:324:9)
    at Object.<anonymous> (/home/kostya/tmp/pg-test/t.js:5:11)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)
dfilatov commented 7 years ago

@ikokostya Thank you for the report!

dfilatov commented 7 years ago

Fixed in 0.4.16