Netflix / falcor

A JavaScript library for efficient data fetching

Home Page:http://netflix.github.io/falcor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

value is "message": "Response code 0"

mickael-kerjean opened this issue · comments

Hello,

I start to put my head on falcor and wow I'm impress (love the query optimizer, LRU, subscribe). It kick ass so much that I wonder how is it possible nobody went with this solution before.

I'm using falcor router and I keep receiving this kind of error message:

{
        "path": [
            "....."
        ],
        "value": {
            "message": "Response code 0"
        }
},

It seems to happen randomly in my code. Any idea of what situation make this error happen?

My assumption is that your underlying service is throwing this error.

In the past, seems like I've seen XHR requests report response code of "0" when the network is down or the host is unreachable.

@greim Thank you for puttting me on the track
@jhusain Since the error is intermittent, It wasn't trivial to isolate the issue. First time I came into this, I didn't understand how it was possible to have a 0 since it isn't a valid HTTP status code. After browsing into the underlying service code I haven't found anything that could generate this error.

However, browsing into Falcor code, here is what I found:
The error is generated here since the status property of the xhr object is 0 when the request complete.
According to the xhr spec, it happens when:

  • the error flag is set (indicates some type of network error or fetch termination)
  • the state is UNSENT or OPENED

It would be great to manage this case somewhere in here so that if the service doesn't answer (which is the root cause of the issue I was experiencing), the error message provide by falcor make more sense.