Bug Tracker

Opened 6 years ago

Closed 6 years ago

#15050 closed bug (notabug)

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');
});

Change History (1)

comment:1 Changed 6 years ago by dmethvin

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.

Note: See TracTickets for help on using tickets.