mootools/mootools-more — Issue #1052: Request.JSONP race condition with option link: cancel
Author: jtrosby
Created: 2011-10-17 14:56:41+00:00
State: open

I have been able to reproduce this in Firefox only (6 and 7), chrome is ok, IE has not been tested.

The cancel function runs the clear function with destroys the last script element like this:

clear: function(){
this.running = false;
if (this.script){
this.script.destroy();
this.script = null;
}
return this;
},

However, in firefox, this does not actually stop the javascript returned by the jsonp server from running. The reference to this.success in Request.JSONP.request_map still exists for each jsonp request and the callback will be run for all the requests, even the cancelled ones. The order in which the callbacks will execute is random and only the first callback will actually run because of the success function:

success: function(args, index){
if (!this.running) return;
this.clear()
.fireEvent('complete', args).fireEvent('success', args)
.callChain();
},

The first callback will set this.running to false in the clear function and all following callbacks will immediately return because this.running is false.