Skip to main content

Bug Tracker

Side navigation

#15050 closed bug (notabug)

Opened April 24, 2014 12:40PM UTC

Closed April 28, 2014 02:14PM UTC

Deffered callbacks chain brokes after unhadled exception

Reported by: Zinoviev Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.11.0
Keywords: Cc:
Blocked by: Blocking:
Description

If somewhere inside callbacks from then/done etc occurs exception all other callbacks(either success and fail) - will not be called

var deffered = jQuery.Deferred();

    setTimeout(function delayedFn(){
        deffered.resolve();
    }, 2000);

    deffered.done(function(){
        throw new Error('Error');
        console.log('You never see this');
    }).fail(function(err) {
        console.log('And this is also not reachable')
    });

    deffered.done(function(){
        console.log('It will be not called');
    });

Compared to bluebird/Q - except catch() it call fail()/native Chrome implementation

var promise = new Promise(function (resolve, reject) {
    setTimeout(function(){
        resolve('ook!');
    }, 1000);

});

promise.then(function onResolve(val) {
    throw new Error('oops');

}).catch(function(err) {console.log('It will be printed')});

promise.then(function onResolve(){
    console.log('It will be also printed');
});
Attachments (0)
Change History (1)

Changed April 28, 2014 02:14PM UTC by dmethvin comment:1

resolution: → notabug
status: newclosed

Unexpected exceptions in Promise implementations are notoriously hard to debug. Our approach with $.Deferred() was to assume they are programming errors and should be dealt with via the standard debugging mechanisms such as console messages and window.onerror handlers. If you prefer the Bluebird or standard Promise, use those instead.