Re: [XHR2] timeout

On 11/12/2009 05:24 PM, Anne van Kesteren wrote:
> On Wed, 11 Nov 2009 00:03:07 +0100, Jonas Sicking <jonas@sicking.cc> wrote:
>> On Tue, Nov 10, 2009 at 10:17 AM, Anne van Kesteren <annevk@opera.com>
>> wrote:
>>> Anyway, do you have opinions on the synchronous case? Do you agree we
>>> should use TIMEOUT_ERR there? What do the people from Microsoft think?
>>
>> That makes sense to me.
>
> I've now defined the timeout feature:
>
> http://dev.w3.org/2006/webapi/XMLHttpRequest-2/
>
>
> Please review it! (Same for FormData and really all other parts of the
> specification.)
>
>


I think timeout is a bit too limiting. Especially the step
2. "If the send() flag is true raise an INVALID_STATE_ERR exception and 
terminate these steps. "

What if dns resolving (or something else) takes just a bit too long and
then the timeout fires while something is being downloaded.
Whoever is using the API may have already read part of the data and may 
want to get rest of it.
So, could we allow increasing timeout value also after send().
Setting timeout to 0 to clear it should also be possible.

This way one could increase the timeout if needed.
var xhr = new XMLHttpRequest();
xhr.open(...);
xhr.timeout = 10000; //10s
xhr.onprogress = function(evt) {
   // Ok, some progress is happening, increase the timeout so
   // that only very slowly loading XHR is cancelled.
   if (xhr.timeout == 10000) {
     xhr.timeout *= 2;
   }
}
xhr.send();


-Olli

Received on Tuesday, 15 March 2011 13:55:19 UTC