-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Don't show context cancelled errors in attribute reader #19006
Don't show context cancelled errors in attribute reader #19006
Conversation
Fix go-gitea#18997 Signed-off-by: Andrew Thornton <art27@cantab.net>
But we may need to log them? |
…-ctx-closed-errors
Signed-off-by: Andrew Thornton <art27@cantab.net>
c5ca0af
to
dd9e22a
Compare
We don't need to log these. The program being ended because the context has been cancelled is a normal thing and it should not be logged. Similarly the "signal: killed" error will only occur due to the process being killed. This will happen due to context cancellation. These are not errors and should not be logged. |
Why The other expression below is using |
What's your question here? We can ignore both of these as they're expected errors. |
I was asking about the meaning about
Question 1: Is it really correct?For example:
Are they all correct for the expression Even it's correct, it's not obvious, it's hard to imagine that future maintainers can know why it works. Question 2: The error detectionThe other expression is |
ps: to clarify .... the questions above are not a blocker. Maybe only I have the difficulty to understand the logic .... If someone can confirm it's correct, just give the approval (and I would really appreciate if someone could help explain the logic and questions .... 🙏) |
Yes they are all correct. Read the docs for context err. Different errs can be returned from the context err. If a context is cancelled due to its parent being cancelled it will have the same error. It doesn't matter what caused the context to be cancelled it is cancelled. The signal killed error also needs to be ignored due to cmd.Wait sometimes returning that when the exec is killed by the context being out of date. |
If it is the case, I think we should patch Lines 182 to 186 in 98f5408
if err := cmd.Wait(); err != nil && ctx.Err() != context.DeadlineExceeded {
return err
}
if ctx.Err() == context.Canceled {
// if the command (context) is canceled by our code, we shouldn't treat such result as an error
return nil
}
return ctx.Err() Or We just check In this PR, if we use |
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.
IMO err != context.Canceled
could be more clear and correct, and we should report DeadlineExceeded
as error.
If you are sure that c.ctx.Err() != err
is by purpose, the comment could be updated to We should not pass up error due to the context being cancelled or it exceeds deadline
as per wxiaoguang Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Backport go-gitea#19006 Fix go-gitea#18997 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* giteaofficial/main: Add button for issue deletion (go-gitea#19032) Fix script compatiable with OpenWrt (go-gitea#19000) Allow users to self-request a PR review (go-gitea#19030) Fix wrong scopes caused by empty scope input (go-gitea#19029) Feature: show issue assignee on project board (go-gitea#15232) bump go deps (go-gitea#19021) Don't show context cancelled errors in attribute reader (go-gitea#19006) Set `rel="nofollow noindex"` on new issue links (go-gitea#19023) update to correct stable version
Fix go-gitea#18997 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Fix #18997
Signed-off-by: Andrew Thornton art27@cantab.net