Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manifest load error handling fails for cross domain JSONP calls #112

Open
ilinkuo opened this issue Jun 13, 2013 · 3 comments
Open

Manifest load error handling fails for cross domain JSONP calls #112

ilinkuo opened this issue Jun 13, 2013 · 3 comments
Labels
Milestone

Comments

@ilinkuo
Copy link

ilinkuo commented Jun 13, 2013

I found this problem in 1.1.2 and checked that the handling was still the same in 1.2.

When the manifest fails to load, the app is not removed

Root cause: Lines 16523-16528 of https://github.com/OpenF2/F2/blob/master/sdk/f2.debug.js are not invoked

errorFunc = function() {
    jQuery.each(req.apps, function(idx,item){
        F2.log('Removed failed ' +item.name+ ' app', item);
        F2.removeApp(item.instanceId);
    });
},

This is a limitation of jQuery's ajax handler. See http://api.jquery.com/jQuery.ajax/

error
Type: Function( jqXHR jqXHR, String textStatus, String errorThrown )
A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event.

Please make the behavior the same for all requests, regardless of domain.

Implementation suggestion: Put the removal check in the :complete handler and have the success set a flag to be checked.

@ilinkuo
Copy link
Author

ilinkuo commented Jun 17, 2013

It turns out not only is the :error handler not called, the :complete handler is also not called, so my implementation suggestion above will not work.

My temporary local hack to this problem was to create an associated setTimeout which called the removeApp() and place the corresponding clearTimeout in the complete handler. The value of the timeout was set at an arbitrary 6000ms.

@brianbaker
Copy link
Member

Looks like passing a timeout parameter into $.ajax will allow jQuery to call the appropriate handlers. http://jsfiddle.net/rekabnairb/EJJbv/

@ilinkuo
Copy link
Author

ilinkuo commented Jun 25, 2013

That timeout seems good to me.... I've found that it is a little tricky and haven't quite figured out how to do this. The problem is that even if the timeout causes the error handler to be thrown and then the app is removed, if the request comes back after the timeout, the code in the request will still run. There has to be a way to prevent the slow-loading code from running at all.

@brianbaker brianbaker added this to the 2.0 milestone Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants