forked from NYANDEV/forgejo
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>
This commit is contained in:
parent
bb77e6c12d
commit
d4a075d738
1 changed files with 8 additions and 0 deletions
|
@ -9,9 +9,11 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"errors"
|
||||||
"html"
|
"html"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
@ -264,6 +266,12 @@ func (ctx *Context) ServerError(logMsg string, logErr error) {
|
||||||
func (ctx *Context) serverErrorInternal(logMsg string, logErr error) {
|
func (ctx *Context) serverErrorInternal(logMsg string, logErr error) {
|
||||||
if logErr != nil {
|
if logErr != nil {
|
||||||
log.ErrorWithSkip(2, "%s: %v", logMsg, logErr)
|
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 {
|
if !setting.IsProd {
|
||||||
ctx.Data["ErrorMsg"] = logErr
|
ctx.Data["ErrorMsg"] = logErr
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue