meteor / promise

ES6 Promise polyfill with Fiber support
MIT License
63 stars 15 forks source link

catch unhandled rejections #5

Closed art-in closed 9 years ago

art-in commented 9 years ago

I've noticed that with default Meteor's then/promise polyfill there is no way to catch unhandled rejections. https://github.com/then/promise/issues/70

To solve this I'm looking for some way to replace then/promise with petkaantonov/bluebird, since bluebird can do process.on("unhandledRejection", function() {...})

I've tried to meteor add mvrx:bluebird, but looks like Meteor's core promise polyfill hides bluebird since "unhandledRejection" does not catch, and this fails: if (!Promise.noConflict) { throw Error('NO BLUEBIRD'); }

Any ideas?

art-in commented 9 years ago

Hopefully then/promise has non standard .done() method, which throws unhandled rejection outside the promise. So it is not a problem for me anymore.

promise
    .then(function() {
        throw 'BOOM'
    })
    .done() // exception thrown outside
benjamn commented 9 years ago

I've been thinking about reducing the scope of this package so that users have to provide their own Promise implementation, which should make it easier to use in an existing environment where you already have a preferred polyfill. Would that be better for you, even though you found a workaround in this case?

art-in commented 9 years ago

@benjamn Yes, I think such option still would be better. Namely because then/promise forces me to use non Promise+ standard .done() method.