🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Discard request for image canceled by the client before any further processing
Deluan588ee94f7c75
diff --git a/server/public/handle_images.go b/server/public/handle_images.goindex 53e87485e..7d73c8b95 100644--- a/server/public/handle_images.go+++ b/server/public/handle_images.go@@ -14,6 +14,11 @@ import ()func (p *Router) handleImages(w http.ResponseWriter, r *http.Request) {+ // If context is already canceled, discard request without further processing+ if r.Context().Err() != nil {+ return+ }+ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)defer cancel()id := r.URL.Query().Get(":id")@@ -27,10 +32,9 @@ func (p *Router) handleImages(w http.ResponseWriter, r *http.Request) {http.Error(w, err.Error(), http.StatusBadRequest)return}-size := utils.ParamInt(r, "size", 0)- imgReader, lastUpdate, err := p.artwork.Get(ctx, artId, size)+ imgReader, lastUpdate, err := p.artwork.Get(ctx, artId, size)switch {case errors.Is(err, context.Canceled):returndiff --git a/server/subsonic/media_retrieval.go b/server/subsonic/media_retrieval.goindex 2d9d161d0..1190c6306 100644--- a/server/subsonic/media_retrieval.go+++ b/server/subsonic/media_retrieval.go@@ -53,6 +53,11 @@ func (api *Router) getPlaceHolderAvatar(w http.ResponseWriter, r *http.Request)}func (api *Router) GetCoverArt(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {+ // If context is already canceled, discard request without further processing+ if r.Context().Err() != nil {+ return nil, nil //nolint:nilerr+ }+ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)defer cancel()