Skip to content

Commit 1037853

Browse files
committed
If rendering has failed due to a net.OpError stop rendering
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 <[email protected]>
1 parent 7b6c1f8 commit 1037853

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

modules/context/context.go

+8
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"
@@ -265,6 +267,12 @@ func (ctx *Context) ServerError(logMsg string, logErr error) {
265267
func (ctx *Context) serverErrorInternal(logMsg string, logErr error) {
266268
if logErr != nil {
267269
log.ErrorWithSkip(2, "%s: %v", logMsg, logErr)
270+
if errors.Is(logErr, &net.OpError{}) {
271+
// This is an error within the underlying connection
272+
// and further rendering will not work so just return
273+
return
274+
}
275+
268276
if !setting.IsProd {
269277
ctx.Data["ErrorMsg"] = logErr
270278
}

0 commit comments

Comments
 (0)