-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Prevent loop if there is an error in GetNotificationCount #19799
Prevent loop if there is an error in GetNotificationCount #19799
Conversation
If the context is cancelled `.NotificationUnreadCount` in a template can cause an infinite loop with `ctx.ServerError()` being called, which creates a template that then calls `.NotificationUnreadCount` calling `GetNotificationCount()` with the cancelled context resulting in an error that calls `ctx.ServerError`... and so on... This PR simply stops calling `ctx.ServerError` in the error handler code for `.NotificationUnreadCount` as we have already started rendering and so it is too late to call `ctx.ServerError`. Additionally we skip logging the error if it's a context cancelled error. Fix go-gitea#19793 Signed-off-by: Andrew Thornton <art27@cantab.net>
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.
Wonder if there are more similar cases
searching through the codebase for It genuinely looks like this is the only place - but obviously we need to be more careful in future. |
* giteaofficial/main: Prevent loop if there is an error in GetNotificationCount (go-gitea#19799) Add 'make tidy' (go-gitea#19800) Update document to use FHS `/usr/local/bin/gitea` instead of `/app/...` for Docker (go-gitea#19794)
…9799) If the context is cancelled `.NotificationUnreadCount` in a template can cause an infinite loop with `ctx.ServerError()` being called, which creates a template that then calls `.NotificationUnreadCount` calling `GetNotificationCount()` with the cancelled context resulting in an error that calls `ctx.ServerError`... and so on... This PR simply stops calling `ctx.ServerError` in the error handler code for `.NotificationUnreadCount` as we have already started rendering and so it is too late to call `ctx.ServerError`. Additionally we skip logging the error if it's a context cancelled error. Fix go-gitea#19793 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
If the context is cancelled
.NotificationUnreadCount
in a template cancause an infinite loop with
ctx.ServerError()
being called, whichcreates a template that then calls
.NotificationUnreadCount
callingGetNotificationCount()
with the cancelled context resulting in anerror that calls
ctx.ServerError
... and so on...This PR simply stops calling
ctx.ServerError
in the error handler codefor
.NotificationUnreadCount
as we have already started rendering andso it is too late to call
ctx.ServerError
. Additionally we skiplogging the error if it's a context cancelled error.
Fix #19793
Signed-off-by: Andrew Thornton art27@cantab.net