Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#14090 closed defect (fixed)

dojo.Deferred notify is not propagating progressHandler calls

Reported by: skaegi Owned by: Kris Zyp
Priority: high Milestone: 1.7
Component: General Version: 1.6.1
Keywords: Cc: Dustin Machi
Blocked By: Blocking:

Description

We're using Deferred's progress support to get incremental updates for long running operations. Things work fine when the then is placed directly on the deferred however we noticed that progress() was not getting called when a deferred was returned in a chain.

The problem is in Deferred.notify where the listener's "progress" call is not getting propagated along with "resolve" and "reject".

In Deferred.notify it should be:

newResult.then(dojo.hitch(listener.deferred, "resolve"), dojo.hitch(listener.deferred, "reject"), dojo.hitch(listener.deferred, "progress"));

but is currently:

newResult.then(dojo.hitch(listener.deferred, "resolve"), dojo.hitch(listener.deferred, "reject"));

Change History (7)

comment:1 Changed 8 years ago by skaegi

FWIW it's worth we are currently using this patched in our product.

I logged against 1.6.1 but we still see the problem in the dojo trunk -- https://github.com/dojo/dojo/blob/master/_base/Deferred.js#L177

comment:2 Changed 8 years ago by Adam Peller

Owner: set to Kris Zyp

comment:3 Changed 8 years ago by skaegi

Here's a quick test to illustrate... The second test will fail right now and pass after patching Deferred.

function testDojoPromiseProgressBasic() {
	var a = new dojo.Deferred();
	var b = new dojo.Deferred();
	var called = false;
	
	a.then(function() {
		b.then(function(){
			if (!called) {
				console.log("Boo. ProgressBasic not called");
			}
		}, function(){
			console.log("Unexpected");
		}, function(){
			called = true; 
			console.log("Yay. ProgressBasic called");
		});
	});
	
	a.resolve();
	b.progress();
	b.resolve();
};

function testDojoPromiseProgressChain() {
	var a = new dojo.Deferred();
	var b = new dojo.Deferred();
	var called = false;
	
	a.then(function() {
		return b;
	}).then(function(){
		if (!called) {
			console.log("Boo. ProgressChain not called");
		}
	}, function(){
		console.log("Unexpected");
	}, function(){
		called = true; 
		console.log("Yay. ProgressChain called");
	});
	
	a.resolve();
	b.progress();
	b.resolve();
};
testDojoPromiseProgressBasic();
testDojoPromiseProgressChain();

comment:4 Changed 8 years ago by Adam Peller

Cc: Dustin Machi added

comment:5 Changed 8 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

In [26866]:

Propagate progress, fixes #14090 !strict

comment:6 Changed 8 years ago by Kris Zyp

In [26867]:

Added tests for propagate progress, fixes #14090 !strict

comment:7 Changed 8 years ago by Adam Peller

Milestone: tbd1.7
Note: See TracTickets for help on using tickets.