Ajax requests timeout after 1 minute in iOS10, even if the ajax timeout is greater than 1 minute

Originator:gwynjudd
Number:rdar://28810194 Date Originated:18/10/2016
Status:Open Resolved:
Product:iOS Product Version:10
Classification: Reproducible:Always
 
Area:
WebKit

Summary:
We make an ajax request in javascript much like this:

$.ajax({
  timeout: 120000, // 2 minutes timeout
  url: url // a request to a url - the request to the server is known to take between 1 and 2 minutes
});

The request will error after 2 minutes, even though we know from debugging at the server that it was successfully handled and the response was sent at sometime between 1 and 2 minutes. We see an error in the log at that time "Failed to load resource:  The request timed out."

It is acting as though the request actually took longer than 2 minutes to process, although we know that not to be the case.

We see this issue in our iOS app which is using the iOS webview control.

Steps to Reproduce:
Create a website with an ajax request as above. Connect to the site and make the request

Expected Results:
The request will succeed at some time between 1 and 2 minutes

Actual Results:
The request errors as explained above

Version:
iOS 10.1 (14B55c)

Notes:
I will try installing iOS 10.1 beta 4 to see if the issue resolves

Configuration:
iPad air 2

Attachments:

Comments

Here is a simpler piece of code that will replicate the issue without requiring jQuery

            var xmlhttp = new XMLHttpRequest();

            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == XMLHttpRequest.DONE) {
                    if (xmlhttp.status == 200) {
                        alert('Request succeeded');
                    }
                    else if (xmlhttp.status == 400) {
                        alert('There was an error 400');
                    }
                    else {
                        alert('Request errored: ' + xmlhttp.status);
                    }
                }
            };

            xmlhttp.open("POST", "...", true);
            xmlhttp.setRequestHeader("Content-Type", "application/json; charset=utf-8");

            let data = {
                ...
            };

            xmlhttp.send(JSON.stringify(data));

It will error at 1 minute, instead of succeeding the query at some time between 1 and 2 minutes


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!