Skip to main content

Bug Tracker

Side navigation

#10836 closed bug (invalid)

Opened November 19, 2011 08:04PM UTC

Closed November 20, 2011 12:26AM UTC

Last modified January 14, 2012 10:43AM UTC

$.when().always() only passes results of rejected promises

Reported by: ryanneufeld Owned by:
Priority: high Milestone: 1.next
Component: deferred Version: 1.7.1rc1
Keywords: Cc:
Blocked by: Blocking:
Description

The behaviour of always() is not what is expected. It get's fired every time, however if one of the promises passed does not resolve, none of the successful data is passed to the callback. Instead a workaround/duck punch of using .pipe() is required.

http://jsfiddle.net/ryanneufeld/xRWDc/7/ -- Current behaviour

http://jsfiddle.net/ryanneufeld/xRWDc/8/ -- duck punched w/ .pipe()

pipe() is serving its purpose here, however always should be getting the resolved values and the rejected values. This would allow for a semantic coding style of rejecting and resolving deferreds while giving developers to write a single function to deal with all the results.

Attachments (0)
Change History (3)

Changed November 19, 2011 08:24PM UTC by timmywil comment:1

component: unfileddeferred
milestone: None1.next
priority: undecidedhigh
status: newopen
version: git1.7.1rc1

Confirmed. Maybe this should be considered for 1.7.1.

Changed November 20, 2011 12:26AM UTC by jaubourg comment:2

resolution: → invalid
status: openclosed

You can't generalize this behaviour.

The Promise returned by $.when is rejected if and _as soon as_ one of the joined Promises is rejected. This is needed because you can't assume the other Promises will actually get resolved or rejected: http://jsfiddle.net/2LgZG/

What you want is something else than $.when with semantics that involve none of the passed Promises stay in the pending state.

Changed January 14, 2012 10:43AM UTC by jaubourg comment:3

#11162 is a duplicate of this ticket.