-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Error thrown in xhr.onreadystatechange when javascript execution is suspended/resumed on iOS #6582
Conversation
…to ignore multiple calls. #5426
Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS. Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match. If you signed the CLA as a corporation, please let us know the company's name. Thanks a bunch! PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR. |
Sorry. It's done. |
CLA signature verified! Thank you! Someone from the team will now triage your PR and it will be processed based on the determined priority (doc updates and fixes with tests are prioritized over other changes). |
02dc2aa
to
fd2d6c0
Compare
cad9560
to
f294244
Compare
e8dc429
to
e83fab9
Compare
4dd5a20
to
998c61c
Compare
@peleteiro could you please confirm that it still happens with 1.3.x? The reason I'm asking is that the |
@pkozlowski-opensource This was fixed a while ago in 1.2 by confirming that xhr was still set (and unsettling it when the request was completed) In 1.3 it shouldn't occur, when I removed the onreadystatechange handler I've tested that on load is only called once using the iOS 7 simulator. I believe this can be closed. |
Request Type: bug
How to reproduce: 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
Component(s): $http
Impact: large
Complexity: small
This issue is related to:
Detailed Description:
In certain cases Webkit will call the onreadystatechange method of a single XMLHttpRequest object multiple times indicating that it is ready (readyState == 4).
Other Comments:
The actual approach didn't work. I took the Zepto.js approach (see: madrobby/zepto#633).
In addition to manual and unit tests, I run a angular website with 250k unique visitor a day, I tested this patch there using getsentry.com and got no erros.
See: #5426