-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
[bugfix] Overwrite API client closed errors with 499 - Client Closed Request
#1857
Conversation
internal/gtserror/withcode.go
Outdated
@@ -45,6 +48,10 @@ type withCode struct { | |||
code int | |||
} | |||
|
|||
func (e withCode) Original() error { |
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.
It would probably be here to instead implement this as Unwrap() error
because then it will fit the errors.Unwrap()
and errors.Is()
function interface requirements :)
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.
Done! I hope i did it right anyways 🤔
@@ -23,13 +23,21 @@ import ( | |||
"strings" | |||
) | |||
|
|||
const ( | |||
StatusClientClosedRequest = 499 |
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'd maybe add a note here explaining these are only here because net/http
doesn't contain them
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.
Done!
internal/api/util/errorhandling.go
Outdated
clientClosed = ctxErr != nil && (errors.Is(ctxErr, context.Canceled) || errors.Is(ctxErr, context.DeadlineExceeded)) | ||
) | ||
|
||
if clientClosed { |
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 you could probably just do if err := c.Request.Context().Err(); err != nil {
here, not needing the above. Any returned context error here will be the base context that was originally set on the request and will only ever be one of deadline exceeded / canceled. What do you think?
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.
Got it! Thanks :) Fixed!
… Request` (#1857) * [bugfix] Overwrite client closed errors with 499 * bleep bloop * review changes
Description
This pull request updates error logging in aputil to check if the error came about because the requester hung up the request before it could be completed. If so, whatever errWithCode was given is replaced with a less alarming error, that indicates that the client already closed the request before we could process it.
Not a standard error code, but then again it doesn't really matter because the client isn't going to see it anyway...
This should make it easier to debug GtS, since the logs won't show so many superfluous error messages.
Checklist
Please put an x inside each checkbox to indicate that you've read and followed it:
[ ]
->[x]
If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).
go fmt ./...
andgolangci-lint run
.