PDA

View Full Version : XmlHttpRequest transaction abort


bnumnum
07-24-2007, 06: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.

mystix
07-24-2007, 08:26 AM
thanks for tracing through this.

which Ext build did u test this on - 1.0.1a / 1.1RC1?

bnumnum
07-24-2007, 09:23 AM
1.1RC1

jack.slocum
07-28-2007, 08:07 AM
The abort not being cleared should have no adverse affect as it is ignored if it is no longer valid.

As for trying to manually fix Firefox's timeout intervals, that's not something we intend to do. On most platforms (including windws) the millisecond data provided by getTime() is not even as accurate as the intervals.