-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update to xhr 2.0.0 breaks on errors #46
Comments
Thanks for creating an issue. We're looking into this and will keep you posted. |
@mkaminsky would you mind trying out the fix I published in #47? |
Thank you for the quick response. Your new commit turns the unsuccessful http request into an error, but I think that there still is a problem in how the error is handled. Your commit creates an Error object in
which then propagates to The
Then, when Perhaps this actually raises a more fundamental issue, in that the error object returned via the "client" path is different from the one returned via the "server" path (where there is no http request, statusCode, etc.). |
Yes you're right. The The Thanks again for bringing these things up. |
Woo, ok. Sorry for the delay on this, we basically had to reverse engineer what was going on in @mkaminsky I created a new PR that should fix everything that was broken: #48. Would you mind testing this out? I have tested against our example code and against the todo flux-example with success. We need to add some client-side tests to make sure we're not broken by our dependency in the future. Will add an issue for this. |
The new version seems to work for me. Thanks again everyone. |
After the update to
xhr 2.0.0
, it seems that the error handling path offetchr
, when accessed from the client side, is breaking. In the new version,xhr
no longer returns an error in the callback for HTTP errors--their documentation now reads, "Your callback will be called with anError
if there is an error in the browser that prevents sending the request. A HTTP 500 response is not going to cause an error to be returned.").fetchr
'shttp.client.js:io()
function seems to assume the old behavior. Thus, if the xhr call produces a status code 500, for example,err
will still be false and the success callback will be called. That, in turn, results in a JSON parsing error.The easy way to see this is to run the
fetchr-simple-example
, comparing the current HEAD and a commit just before the upgrade toxhr 2.0.0
. By default, they both behave the same. Even if one changes the flickr API key to something invalid, everything still works because flickr returns its error in the body of its response with HTTP status 200. To see the problem, change the code on line 27 ofserver/fetchers/flickr.js
to return an error:Then, access
localhost:3000/client
. In both case, thexhr
call returns a HTTP status of 400:With the old version of
xhr
, the client throws an error, as expected. With the new version, I get the following:Because of the new
xhr 2.0.0
semantics, theio()
function doesn't think there was any error and executes the success path, resulting in the parsing error. I didn't look into it, but the unit tests don't seem to catch this.(As a side note, I ran into this problem while playing around with
flux-examples
, which usefetchr
viafluxible-plugin-fetchr
. Thetodo
service, for instance, returns errors in this way.)The text was updated successfully, but these errors were encountered: