Closed Bug 926208 Opened 11 years ago Closed 11 years ago

xmlhttprequest timeout doesn't work

Categories

(Core :: DOM: Core & HTML, defect)

24 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: aquilax, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0 (Beta/Release) Build ID: 20130910160258 Steps to reproduce: I have a user script, which send xml http request to a rest service, the response can be very big and the service can take over one minute to reply, so I have added a timeout of two minutes to the request. var xhr=new XMLHttpRequest(); xhr.timeout=2*60*1000; xhr.ontimeout=ontimeoutRequest; Actual results: The request ends after one minute, I see it in firebug, and the timeout event never fire. Expected results: The request should wait two minutes before timeout and after two minutes fire the timeout event.
Aquila, this may be a dupe of bug 805571 or bug 868697. I am not sure if the documentation is incorrect or if there is a bug related to the request timeouts. You might take a look for now at the comments in bug 525816 as well.
Component: Untriaged → DOM
Product: Firefox → Core
Aquila, can you post the entirety of the code you use to set up and dispatch the XHR? Also, if Mozilla's own networking code aborts the request before the timeout is reached, there's really no support for that. (No one to my knowledge has tried firing a XHR with a timeout of an hour, or a day, for example... so I don't know how Mozilla code would react.)
If the request is processed within one minute, why should a 2 minute timeout fire ever? Looks like the spec is odd here. Something has happened to it, since I think it was less wrong at some point. Right now it doesn't normatively define when to dispatch timeout event.
Flags: needinfo?(annevk)
Nm, it is there. "timeout error". So the event should be dispatched while we're processing the request. But the spec should be more clear.
Flags: needinfo?(annevk)
Based on the comment 0 this is invalid, but if there is a testcase which shows timeout isn't dispatched while the request is still active, please reopen.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → INVALID
@Alex Vincent The code is very simple, is generic and used from many other functions. var xhr=new XMLHttpRequest(); xhr.open("GET",url); xhr.onload=requestLoad; xhr.timeout=2*60*1000; xhr.ontimeout=requestTimeout; xhr.send(); Timeout is in milliseconds, at least according to the documentation https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest @Olli Pettay The timeout is two minutes but after one minute the request timeouts, this is visible in firebug. It's not so easy to create a test case, you must set up a web service that doesn't end the request and keep the connection open, something likes the long polling (http://en.wikipedia.org/wiki/Push_technology#Long_polling).
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.