Suppress benign broken pipe and context closed warnings (#2927)

This commit is contained in:
DingDongSoLong4
2022-09-19 07:01:40 +02:00
committed by GitHub
parent 5e97ecd260
commit 8efbcc1c4d
11 changed files with 172 additions and 105 deletions

View File

@@ -2,6 +2,7 @@ package api
import (
"context"
"errors"
"net/http"
"strconv"
@@ -44,8 +45,11 @@ func (rs performerRoutes) Image(w http.ResponseWriter, r *http.Request) {
image, _ = rs.performerFinder.GetImage(ctx, performer.ID)
return nil
})
if errors.Is(readTxnErr, context.Canceled) {
return
}
if readTxnErr != nil {
logger.Warnf("couldn't execute getting a performer image from read transaction: %v", readTxnErr)
logger.Warnf("read transaction error on fetch performer image: %v", readTxnErr)
}
}
@@ -54,7 +58,7 @@ func (rs performerRoutes) Image(w http.ResponseWriter, r *http.Request) {
}
if err := utils.ServeImage(image, w, r); err != nil {
logger.Warnf("error serving image: %v", err)
logger.Warnf("error serving performer image: %v", err)
}
}
@@ -67,11 +71,12 @@ func (rs performerRoutes) PerformerCtx(next http.Handler) http.Handler {
}
var performer *models.Performer
if err := txn.WithTxn(r.Context(), rs.txnManager, func(ctx context.Context) error {
_ = txn.WithTxn(r.Context(), rs.txnManager, func(ctx context.Context) error {
var err error
performer, err = rs.performerFinder.Find(ctx, performerID)
return err
}); err != nil {
})
if performer == nil {
http.Error(w, http.StatusText(404), 404)
return
}