Opened 7 years ago

Closed 7 years ago

#15372 closed defect (worksforme)

[regression]XHR error not triggered when connection is down

Reported by: Adam Peller Owned by: Bryan Forbes
Priority: high Milestone: 1.8
Component: IO Version: 1.7.1
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by Adam Peller)

Test case:

dojo.xhrGet({url:"http://localhost:801",sync:false}).then(function(x,y){console.log("SUCCESS!"+x+","+y)},function(z){console.log("error:"+z)})

Assuming nothing is running on port 801 (or use any invalid URL or even just turn off the network connection on your machine)

An exception occurs on the console (Chrome) but strangely it doesn't seem possible to catch that exception when the xhr is async. dojo.xhr proceeds as if the connection were successful, calling the deferred callback for success. Because xhr status is 0 and readyState is 4, there's really no way to differentiate this from a successful connection in _isDocumentOk.

One possible fix is to go back to checking protocol, since status:0 should only be valid for certain protocols like file:. Unfortunately, this is a slippery slope, as there are a bunch of specialized protocols and situations where status:0 is ok, like appcache. Not sure exactly why we stopped checking protocol, but that may be one reason. It was also very verbose code.

Another possible fix is to use ProgressEvent (XHR2?) at least where it is available. It would be good to fix this on dojo.xhr, even if dojo.request solves the problem. We're using the /dojo/io/error topic, and xhr is obviously used a lot.

This is likely a regression from whenever we changed the _isDocumentOk code.

Change History (8)

comment:1 Changed 7 years ago by Adam Peller

Description: modified (diff)
Priority: undecidedhigh

comment:2 Changed 7 years ago by Adam Peller

yah, that change to _isDocumentOk would have been mine... r22544 then I apparently backed it out. See #12516

Last edited 7 years ago by Adam Peller (previous) (diff)

comment:3 Changed 7 years ago by Adam Peller

Description: modified (diff)

comment:4 Changed 7 years ago by Adam Peller

Milestone: tbd1.8

comment:5 Changed 7 years ago by Colin Snover

Milestone: 1.82.0

1.8 has been tagged; moving all outstanding tickets to next major release milestone.

comment:6 Changed 7 years ago by Adam Peller

Milestone: 2.01.8.1
Summary: XHR error not triggered when connection is down[regression]XHR error not triggered when connection is down

comment:7 Changed 7 years ago by Adam Peller

bump. what's the best way forward on this? Can we use the ProgressEvents? API? Is there any other way to fix isDocumentOk?

comment:8 Changed 7 years ago by Adam Peller

Milestone: 1.8.11.8
Resolution: worksforme
Status: newclosed

now publishes on topic /dojo/io/error with status:0

Note: See TracTickets for help on using tickets.