-
Notifications
You must be signed in to change notification settings - Fork 85
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
Fetch error handling is incorrect #1655
Labels
bug
Something isn't working
Comments
Open
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the code below we're assuming that if response.json() throws an error, it means we have a communication error. This is incorrect, it will only throw if the request body isn't valid JSON (https://fetch.spec.whatwg.org/#dom-body-json). As long as we can be 100% sure that Meilisearch client will only respond with a valid JSON error body text, this will never throw. If that isn't the case, maybe we should instead use response.text().
meilisearch-js/src/errors/http-error-handler.ts
Lines 5 to 26 in cd61a8c
A communication error, or a network error would rather occur in the code below, before it gets to
httpResponseErrorHandler
, as described in the docs, and would be caught below and processed byhttpErrorHandler
.meilisearch-js/src/http-requests.ts
Lines 165 to 174 in cd61a8c
Now, this
httpErrorHandler
messes with the error in such a way that information gets lost, which is another bug in itself, related to and detailed in #1612, and that's another issue that I should probably address separately.The text was updated successfully, but these errors were encountered: