aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-02-07 01:25:05 +0000
committerGitHub <noreply@github.com>2022-02-07 09:25:05 +0800
commitd4a075d73815c3bc0591deae5171a14401dc3f66 (patch)
tree146730233b9fcb415ad38abfa7687fe0bef54f97 /modules
parentbb77e6c12dd0c261e56d15ee0d6db7cae4d3d6f7 (diff)
downloadgitea-d4a075d73815c3bc0591deae5171a14401dc3f66.tar.gz
gitea-d4a075d73815c3bc0591deae5171a14401dc3f66.zip
If rendering has failed due to a net.OpError stop rendering (#18642) (#18645)
Backport #18642 When a net.OpError occurs during rendering the underlying connection is essentially dead and therefore attempting to render further data will only cause further errors. Therefore in serverErrorInternal detect if the passed in error is an OpError and if so do not attempt any further rendering. Fix #18629 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules')
-rw-r--r--modules/context/context.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/context/context.go b/modules/context/context.go
index dd571b4d78..c7b9c0615c 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -9,9 +9,11 @@ import (
"context"
"crypto/sha256"
"encoding/hex"
+ "errors"
"html"
"html/template"
"io"
+ "net"
"net/http"
"net/url"
"path"
@@ -264,6 +266,12 @@ func (ctx *Context) ServerError(logMsg string, logErr error) {
func (ctx *Context) serverErrorInternal(logMsg string, logErr error) {
if logErr != nil {
log.ErrorWithSkip(2, "%s: %v", logMsg, logErr)
+ if errors.Is(logErr, &net.OpError{}) {
+ // This is an error within the underlying connection
+ // and further rendering will not work so just return
+ return
+ }
+
if !setting.IsProd {
ctx.Data["ErrorMsg"] = logErr
}