-
Notifications
You must be signed in to change notification settings - Fork 7
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
Sort service errors into the proper subclass #252
Conversation
@ptpaterson you've got some tests failing. |
It's unrelated to the streaming tests. Looks like a check for client-timeout is being flaky. |
Can you try to deflake it? |
4856cb1
to
d0ae467
Compare
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.
Error classes have been updated.
Fixes:
invalid_query
is the only realQueryCheckError
code
Streaming changes
FetchClient
andNodeHTTP2Client
returnNetworkErrors
when problems are encountered after the stream is connected.
New breaking changes compared to v1.3.1
- The
httpStatus
field forServiceError
s is now optional - Added a
ConstraintFailureError
class and broke that out fromQueryRuntimeError
- Merged the
ServiceTimeoutError
class into theQueryTimeoutError
class. They share the sametime_out
code.
readonly httpStatus: number; | ||
readonly httpStatus?: number; |
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.
Chose to make httpStatus optional. This seemed more consistent with encouraging folks to not rely on the HTTP status code than the sentinel -1.
However, it will break any existing Typescript code that reads error.httpStatus without guarding against null.
* A failure due to the timeout being exceeded, but the timeout | ||
* was set lower than the query's expected processing time. | ||
* This response is distinguished from a ServiceTimeoutException | ||
* in that a QueryTimeoutError shows Fauna behaving in an expected | ||
* manner. | ||
* A failure due to the query timeout being exceeded. | ||
* | ||
* This error can have one of two sources: | ||
* 1. Fauna is behaving expectedly, but the query timeout provided was too | ||
* aggressive and lower than the query's expected processing time. | ||
* 2. Fauna was not available to service the request before the timeout was | ||
* reached. | ||
* | ||
* In either case, consider increasing the `query_timeout_ms` configuration for | ||
* your client. | ||
*/ | ||
export class QueryTimeoutError extends ServiceError { |
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 merged the ServiceTimeoutError class into QueryTimeoutError. We talk about "client timeouts" vs "query timeouts" so I think that's the appropriate name, and QueryTimeoutError already had optional stats field defined.
6a13ee0
to
45dbcb9
Compare
Ticket(s): FE-5040
Problem
HTTPStreamClient
implementations need to throw service errors if the initial response is a non-200. The logic to convertQueryFailure
responses to the appropriate sub type is currently a private method on theClient
class.The
StreamClient
also needs to throw the appropriate service error class when a type=error event is received.Solution
Move the
Client.#getServiceError
method to theerrors
module so it can be reused. Use it to throw the appropriate error if a type=error event is received or if the initial response is a non-200.There is no http status code associated with streaming error events, so we should update error handling to rely first on the error code, then fallback to the base
ServiceError
if the error code is not matched.Out of scope
N/A
Testing
Updated tests to check that the appropriate errors are thrown.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.