-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[ENH]: Improved error reporting #1817
[ENH]: Improved error reporting #1817
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
clients/js/src/ErrorHandlingFetch.ts
Outdated
init?: RequestInit | ||
): Promise<Response> => { | ||
try { | ||
return await fetch(input, init); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think fetch will not raise if status is 500 no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's a good call. I think we may need to have a larger conversation about what we want our policy to be for these things (although I guess that's my task :) ). Ideally, we'd have a standardized error API at the client level.
e.g.
ChromaConnectionError
ChromaServerError
ChromaUnknownError
298cc78
to
c681064
Compare
} catch (e) { | ||
expect(e instanceof Error).toBe(true); | ||
expect((e as Error).message).toMatchInlineSnapshot( | ||
`"Failed to connect to chromadb. Make sure your server is running and try again. If you are running from a browser, make sure that your chromadb instance is configured to allow requests from the current origin using the CHROMA_SERVER_CORS_ALLOW_ORIGINS environment variable."` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super nice!
A frequent problem I see is JS sucks with dual-stack systems where most people will connect to localhost, which maps to :1; however, their server is listening on 127.0.0.1. Can we force JS to try both stacks before giving up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is an interesting question. My gut reaction is that it might cause some surprising behaviors in certain circumstances (e.g. the user has something else running at :1:8000 which causes some cryptic errors).
I think that would be a good conversation to have but I think adding that functionality would be outside of the original scope of this PR.
clients/js/src/Errors.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlabasterAxe, the backend sometimes returns error
+ message
, sometimes just error
. Could that break some of the code below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when you say error
+ message
, is that on the response body?
or are you referring to the message field on the error object? that can get thrown by the call to fetch
?
7249215
to
f52cddf
Compare
Description of changes
This PR reworks the way error handling works with the JavaScript client. Previously, the api would return objects with error messages under certain circumstances and throw errors in other circumstances. This standardizes that by supplying a custom fetch implementation that translates the http error codes and the server error responses, into a standardized set of errors that are thrown by the client functions.
Test plan
Documentation Changes