-
Notifications
You must be signed in to change notification settings - Fork 119
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
Should handle empty responses (e.g., CORS errors) #579
Comments
As awesome as it might be to detect this this is actually the intended behavior of the spec. See these StackOverflow answers for a little more detail: basically you cant distinguish between CORS errors and regular network errors because if you COULD then you could maliciously use the failed CORS errors to learn thing about the endpoint you are attacking, like the fact that you can't use CORS or other things. Chrome and Firefox both add their own "pretty" error messages which are what you see above and in these cases: But our application code only ever sees a fetch("https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/?f=json&pretty=true")
.then(r => {
console.log("Response");
debugger;
})
.catch(e => {
console.log("Error");
debugger;
}) We don't attach a The only potential solution would be to add a
|
* #579 with new utilitiy functions and tests * restore coverage * spacing
I'm going to close this. I don't think we need additional documentation on this. It is also going to be tricky to determine what is a network error so we can't really do much about this. |
Some ArcGIS REST requests fail without a response object, for example, when a CORS error occurs.
In this case,
arcgis-rest-js
seems to throw an error with the string"TypeError: Failed to fetch"
instead of the usual error object (see screenshot). This makes it difficult to handle those errors.Would it be possible to handle these more gracefully?
The text was updated successfully, but these errors were encountered: