0.2.59 - Settings save fixes
This commit is contained in:
@@ -414,6 +414,10 @@ func clientLogValue(value string) string {
|
||||
// visible regardless of path.
|
||||
func requestLogLevel(path string, status int) slog.Level {
|
||||
switch {
|
||||
// A request nobody is waiting for any more is not a failure of anything. It is only
|
||||
// ever answered this way deliberately, so it never hides a fault.
|
||||
case status == statusClientClosedRequest:
|
||||
return slog.LevelDebug
|
||||
case status >= http.StatusInternalServerError:
|
||||
return slog.LevelError
|
||||
case status >= http.StatusBadRequest:
|
||||
@@ -557,6 +561,11 @@ func writeRaw(w http.ResponseWriter, status int, body []byte) {
|
||||
_, _ = w.Write(body)
|
||||
}
|
||||
|
||||
// statusClientClosedRequest is nginx's 499. Go has no constant for it because it is not
|
||||
// in the RFC — it exists to say "this was not answered, and that is nobody's fault",
|
||||
// which is a distinction a log is read for and a 5xx destroys.
|
||||
const statusClientClosedRequest = 499
|
||||
|
||||
func writeError(w http.ResponseWriter, status int, message string) {
|
||||
writeJSON(w, status, map[string]string{"error": message})
|
||||
}
|
||||
@@ -566,6 +575,17 @@ func writeError(w http.ResponseWriter, status int, message string) {
|
||||
func (s *Server) writeUpstreamError(
|
||||
ctx context.Context, w http.ResponseWriter, err error, message string,
|
||||
) {
|
||||
// The television having navigated on is not a fault, and it is the ordinary case here:
|
||||
// artwork loaders abandon requests as cards leave the screen, and a detail page warmed
|
||||
// on focus is cancelled the moment the D-pad moves. Reported as 502 it filled the
|
||||
// operator's log with errors describing a launcher working exactly as designed, and
|
||||
// buried the ones that meant something. Nobody is left to read the answer, so it goes
|
||||
// out as 499 — nginx's "client closed request" — and is recorded at DEBUG.
|
||||
if clientGaveUp(ctx, err) {
|
||||
s.loggerFor(ctx).Debug("abandoned before the answer", "detail", message, "error", err)
|
||||
writeError(w, statusClientClosedRequest, "the request was abandoned")
|
||||
return
|
||||
}
|
||||
var apiErr *emby.APIError
|
||||
if errors.As(err, &apiErr) {
|
||||
switch {
|
||||
|
||||
Reference in New Issue
Block a user