Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Request.JSONP race condition with option link: cancel #1052

Open
jtrosby opened this Issue Oct 17, 2011 · 3 comments

Comments

Projects
None yet
2 participants

jtrosby commented Oct 17, 2011 edited by arian

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.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@jtrosby jtrosby closed this Oct 18, 2011

@jtrosby jtrosby reopened this Oct 18, 2011

Owner

arian commented Oct 18, 2011

I was also thinking about just setting that callback to an empty function, so it wouldn't do anything..

jtrosby commented Oct 19, 2011

That would do it too. The code for deleting from request_map isn't required to make it work

@jtrosby jtrosby closed this Oct 19, 2011

@jtrosby jtrosby reopened this Oct 19, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment