-
Notifications
You must be signed in to change notification settings - Fork 86
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
Use structured error types in frontend RPC service #6570
Conversation
7d2cdab
to
c5bb892
Compare
5632e7b
to
a7071c3
Compare
} catch (e) { | ||
message = `unknown (failed to read response body: ${e})`; | ||
if (structuredErrors) { | ||
// If we failed to read the response body then ignore the status code |
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.
Not sure how I feel about this precedence--I guess we still have the network tab to tell the difference, I just figure if a 500 error yielded an unparseable response then saying "500" is more useful than "failed to read".
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 was thinking that this approach would play more nicely with retry middleware (on the frontend) if we return a generic network error here. That way if we return an error status but fail to read the response body, the client can at least retry for a chance to get a more informative error message that could maybe help them fix the error. I guess if the client got permanently disconnected though, they will be stuck with the "failed to read" error, but I think that's not too much worse than 500: <failed to read body>
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 alright, i'm sold
|
||
/** | ||
* High-level error class representing any error from the BuildBuddy server, | ||
* either GRPC or HTTP. |
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.
The class hierarchy is a little weird here based on the documentation--do you actually intend to flip the code on its head at some point (HTTPStatusError extends BBError) or more cleanly compose things so that HTTPStatusError/FetchError etc are held by BBError?
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, thanks for pointing this out - I think what I would like to do is:
- Get rid of
BuildBuddyError
entirely - it's sort of poorly defined - In the places where we're doing stuff like
catch (e) { error_service.handleError(BuildBuddyError.parse(e)); }
we would just passe
instead of trying to parse the error. It's kind of ugly that we "parse" errors at all and I would rather have the errors be nicely structured at a lower level to begin with. - The error_service could then do nicer stuff depending on the type of error that it's rendering, rather than receiving a generic
BuildBuddyError
which is more "watered down". e.g. forFetchError
we could show a nice "network broken" icon or something like that (if we really wanted to, haha)
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.
Sure, that works, how about plopping something in the comment here about what the plan is?
Gah I accidentally merged #6578 into this PR. Fixing up the commits now... |
7982a4d
to
73c7e7d
Compare
} catch (e) { | ||
message = `unknown (failed to read response body: ${e})`; | ||
if (structuredErrors) { | ||
// If we failed to read the response body then ignore the status code |
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 alright, i'm sold
|
||
/** | ||
* High-level error class representing any error from the BuildBuddy server, | ||
* either GRPC or HTTP. |
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.
Sure, that works, how about plopping something in the comment here about what the plan is?
Done |
(This is all behind the
streaming_http_enabled
flag, which is only enabled in dev currently.)This PR is preparing for making server-streaming RPCs retryable on the client. Ideally we'd always retry these, otherwise when the apps roll out, the live-streaming would suddenly stop.
We currently throw a somewhat haphazard mixture of
string
andTypeError
from the RPC service methods when a fetch fails. This PR updates things to be more structured, so that we can more easily distinguish between gRPC status errors, other HTTP errors (with status code + body, but missing gRPC error message), or generic network errors (e.g. can't reach the app, app restarted, etc.).Related issues: N/A