Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#17481 closed defect (invalid)

Deferred does not properly reject listeners if they have reject callbacks

Reported by: Robert Buels Owned by:
Priority: undecided Milestone: tbd
Component: Core Version: 1.9.1
Keywords: Cc:
Blocked By: Blocking:

Description

This code will alert "fail ...", whereas I think it should alert "pass..."

    var d = new Deferred();

    d.then( function() {}, function() {} )
     .then( function() {
               alert('fail. this should not run');
            },
            function() {
               alert('pass. properly rejected.');
            }
          );

    d.reject();

Attachments (1)

deferred_test.html (555 bytes) - added by Robert Buels 6 years ago.
test html file, works from dojo dist root dir

Download all attachments as: .zip

Change History (5)

Changed 6 years ago by Robert Buels

Attachment: deferred_test.html added

test html file, works from dojo dist root dir

comment:2 Changed 6 years ago by Robert Buels

Or, if this is expected behavior, should add a note to the docs for the reject callback saying that a reject callback has to throw the error it's passed in order for the rejection to continue.

That might actually be better, since the current behavior allows listeners to handle rejections and turn them into resolutions.

comment:3 in reply to:  2 Changed 6 years ago by ben hockey

Resolution: invalid
Status: newclosed

Replying to rbuels:

Or, if this is expected behavior, should add a note to the docs for the reject callback saying that a reject callback has to throw the error it's passed in order for the rejection to continue.

That might actually be better, since the current behavior allows listeners to handle rejections and turn them into resolutions.

yeah, this is expected behavior. feel free to update the docs at http://livedocs.dojotoolkit.org/dojo/Deferred if you feel necessary. the typical analogy is try/catch and your error handler is a catch so it needs to re-throw if the error is to be propagated.

comment:4 Changed 6 years ago by Robert Buels

OK, edited the description for then() on http://livedocs.dojotoolkit.org/dojo/Deferred to try to summarize this behavior.

Note: See TracTickets for help on using tickets.