bnumnum
24 Jul 2007, 2:22 AM
I use Ext.Ajax.request to continuously poll a backend service. Every so many calls the xmlhttprequest receives an unwanted abort. After a little bit of tracing i found the following:
1) Ext.lib.Ajax.handleReadyState registers an abort-handler using window.setTimeout ( typically called after 30 seconds). In the same function a cleanup is performed if readyState 4 is detected. The abort-handler-timer however is not cleared by calling window.clearTimeout(oConn.timeout[o.tId]);
2) After performing this modif there were still unwanted abort errors in Firefox.
According to https://bugzilla.mozilla.org/show_bug.cgi?id=291386 and http://pages.mckoss.com/setIntervalTest.htm Firefox sometimes fires its timers to quickly. This sometimes causes the abort-handler to fire too soon and abort an ungoing XmlHttpRequest.
A possible workaround is to pass some extra parameters ( timer-start-timestamp and the timeout-value ) to the abort-handler when the timer is started. In the abort-handler itself one can now compare the current_timestamp versus the timer-start-timestamp + timeout.
If the difference between the two is too big the abort-handler-code is skipped because the timer has fired to quickly. In this case one can also restart the abort-timer with the leftover timeout.
Issues have been detetected on FF/Vista using the ext-base-adapter and the yui-adapter.
I haven't tried the other adpaters.
1) Ext.lib.Ajax.handleReadyState registers an abort-handler using window.setTimeout ( typically called after 30 seconds). In the same function a cleanup is performed if readyState 4 is detected. The abort-handler-timer however is not cleared by calling window.clearTimeout(oConn.timeout[o.tId]);
2) After performing this modif there were still unwanted abort errors in Firefox.
According to https://bugzilla.mozilla.org/show_bug.cgi?id=291386 and http://pages.mckoss.com/setIntervalTest.htm Firefox sometimes fires its timers to quickly. This sometimes causes the abort-handler to fire too soon and abort an ungoing XmlHttpRequest.
A possible workaround is to pass some extra parameters ( timer-start-timestamp and the timeout-value ) to the abort-handler when the timer is started. In the abort-handler itself one can now compare the current_timestamp versus the timer-start-timestamp + timeout.
If the difference between the two is too big the abort-handler-code is skipped because the timer has fired to quickly. In this case one can also restart the abort-timer with the leftover timeout.
Issues have been detetected on FF/Vista using the ext-base-adapter and the yui-adapter.
I haven't tried the other adpaters.