addthis/fluxthis

APIActionCreator - Trigger failure event when there is a networking error

Closed this issue · 4 comments

Currently fluxthis does not currently fire failure events when there is a networking error, such as not having access to the internet.

Good catch. It seems to be tied to the xhr.status !== 0 check here because the status did change from 0.

@AlanFoster what would you expect as a response obj? The status will be 0 which isnt a common check.

@jhorwit2 According to the specification, 0 is the correct status code to check for. It denotes that the message was unsent, either via being offline, or even for things as CORS issues.

We could also bind to onerror if you wished to handle this separately.
There's also a great overview post here

Thoughts?

I'm trying to remember when I wrote this code why I did the explicit check for 0.

Would you happen to know the order of the calls & if it's guaranteed between browsers (i'm sure since this is js that one isn't a thing ;) ) -- onerror, onreadystatechange, onabort? I wasn't able to find this last time I searched the spec/googlez.

^^ I think that's why I did it. I'm completely open to changing this code as long we only send the correct action (success or error) and only once with the correct metadata.