On iOS, javascript execution is suspended when user switches to another tab in browser, closes browser, performs back/forward using swipe gestions.
In our application, if http request is occurred when javascript execution is suspended/resumed, sometimes (apprx one time per dozen tries) the following error is thrown:
TypeError: 'null' is not an object (evaluating 'xhr.readyState')
src/ng/httpBackend.js
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) { // Error is thrown in this line
Debugging showed that xhr.onreadystatechange was invoked several times with readyState=4. On the first invocation xhr was nullified in completeRequest function, and then, on subsequent invocations, error was thrown.
Unfortunately, I could not reproduce the problem in small example. But I found that jQuery and Zepto have appropriate guards. Please see, for example, madrobby/zepto#633
The following change is proposed:
ilplotkin@a79004c