-
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 #5426
Comments
very odd corner case I'm triaging the issue for the next release. thanks for all the info and suggested fix. |
I could reproduce this bug with:
Procedure:
Note: The iOS remote debugger somehow didn't show the error. Had to add manual try/catch inside the |
Thanks for submitting this issue! |
…eadyState=4 On mobile webkit `onreadystatechange` might by called multiple times with `readyState===4` caused by xhrs that are resolved while the app is in the background. Fixes angular#5426.
…eadyState=4 On mobile webkit `onreadystatechange` might by called multiple times with `readyState===4` caused by xhrs that are resolved while the app is in the background. Fixes angular#5426.
Reported as still occuring: #6530 |
Hi,
Here is the sample code that can be used: Put this into
Change the
@peleteiro Could you provide more information how you reproduced this? |
It's hard to reproduce. It happens when you close IOS Safari in the middle of the request. You need help from a getsentry.com kind of tool to get it. But it is well known. If fact this fix was taken from Zepto.js. |
@peleteiro I can reproduce this error without the corresponding fixes that we added to Angular.js (see https://github.com/angular/angular.js/blob/master/src/ng/httpBackend.js#L82). That's why we added them in the first place. However, I can't reproduce the error now any more, with the fixes applied. Are you sure that the problem is still there in current Angular? My testcase was as describe above (in my comment from 3 months ago). |
@peleteiro Waiting for your reply... Otherwise closing this again... |
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')
Debugging showed that
xhr.onreadystatechange
was invoked several times withreadyState=4
. On the first invocationxhr
was nullified incompleteRequest
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
The text was updated successfully, but these errors were encountered: