0

This is happening on Safari iOS 10 Cordova:6.3.1

Request using Angular $http, error function not called

$http.get("http://10.255.255.1").then(function(res){
   console.log("res: " + res);
},function(err){
   console.log("err: " + err);
});

Promise {$$state: {status: 0}, then: function, catch: function, finally: function}

console: Failed to load resource: The request timed out. (10.255.255.1, line 0)


Request using XMLHttpRequest catches timeout error

var xhr = new XMLHttpRequest(); xhr.onload = function () { 
    console.log("request finished") 
}; 
xhr.ontimeout = function (e) { 
    console.log("request timeout") 
}; 
xhr.open('GET', 'http://10.255.255.1', true);
xhr.send(null); 

console: request timeout

FYI: http://10.255.255.1 is a url that I am using to test timeout. Source: Artificially create a connection timeout error

Community
  • 1
  • 1
Sumama Waheed
  • 3,579
  • 3
  • 18
  • 32
  • For reference: This has been fixed in Angular and the fix is/will be included in versions 1.5.9 and 1.6.0-rc.0. See also https://github.com/angular/angular.js/issues/15380. – gkalpak Nov 14 '16 at 09:01

1 Answers1

0

XMLHttpRequest throws an error after 60 seconds even if you increase the timeout.

So it's a iOS 10 WebView thing which is not configurable I believe.

In Angular, If you supply a timeout property less than 60 seconds, an error is properly throw.

Still seems like a bug in Angular. It should still throw and error after request timeout by the WebView.

Sumama Waheed
  • 3,579
  • 3
  • 18
  • 32
  • https://openradar.appspot.com/28810194 is the radr issue about it and https://bugs.webkit.org/show_bug.cgi?id=163814 the fix in webkit – EionRobb Nov 14 '16 at 08:38