Skip to content

Commit 5a8fca2

Browse files
committed
If rendering has failed due to a net.OpError stop rendering (go-gitea#18642)
Backport go-gitea#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 go-gitea#18629 Signed-off-by: Andrew Thornton <[email protected]>
1 parent bb77e6c commit 5a8fca2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

modules/context/context.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import (
99
"context"
1010
"crypto/sha256"
1111
"encoding/hex"
12+
"errors"
1213
"html"
1314
"html/template"
1415
"io"
16+
"net"
1517
"net/http"
1618
"net/url"
1719
"path"
@@ -264,6 +266,12 @@ func (ctx *Context) ServerError(logMsg string, logErr error) {
264266
func (ctx *Context) serverErrorInternal(logMsg string, logErr error) {
265267
if logErr != nil {
266268
log.ErrorWithSkip(2, "%s: %v", logMsg, logErr)
269+
if errors.Is(logErr, &net.OpError{}) {
270+
// This is an error within the underlying connection
271+
// and further rendering will not work so just return
272+
return
273+
}
274+
267275
if !setting.IsProd {
268276
ctx.Data["ErrorMsg"] = logErr
269277
}

0 commit comments

Comments
 (0)