Skip to content
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

200 returned on net::ERR_CONNECTION_REFUSED #14

Closed
kjk opened this issue Jan 12, 2016 · 5 comments
Closed

200 returned on net::ERR_CONNECTION_REFUSED #14

kjk opened this issue Jan 12, 2016 · 5 comments

Comments

@kjk
Copy link

kjk commented Jan 12, 2016

This is Chrome 47.0.2526.106 (64-bit) on Mac.

When testing locally and when the server is not running, a request callback has code = 200 and empty responseText.

This issue is here:

  function cb(statusCode, responseText) {
    return function () {
      if (!called)
        callback(req.status || statusCode,
                 req.response || req.responseText || responseText,
                 req)
      called = true
    }

In my case req.status is 0 but is converted to 200 (statusCode) because it's called from: if (req.readyState === 4) success(). In console I see 'net::ERR_CONNECTION_REFUSED' error.

Not sure what cases are where req.status 0 should be converted to something else. It seems to me this should be reported as error i.e. req.status should be passed as is to the callback.

@yanatan16
Copy link
Owner

Thanks for the report. req.status || statusCode is supposed to catch req.status == undefined, not req.status === 0. I'll patch it to req.status === undefined ? statusCode : req.status

@yanatan16
Copy link
Owner

So this is patched in 8245929. Released as v0.4.1.

Note that nanoajax doesn't do much for you in this case, still giving you a callback with cb(0, "", req). Like other errors in nanoajax, the callback can check the falsyness of the status code.

@kjk
Copy link
Author

kjk commented Jan 13, 2016

Thanks, that will work for my use case.

@yanatan16
Copy link
Owner

@kjk I was thinking about this again, and realized that nanoajax could call back with (0, "Error") instead of (0, ""), so thats now what happens in v0.4.3.

@kjk
Copy link
Author

kjk commented Feb 8, 2016

@yanatan16 sounds like a good idea, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants