From 01f3ce0228278d88411fb3f0ef08aaff1d10d645 Mon Sep 17 00:00:00 2001 From: Deluan Date: Fri, 28 May 2021 11:12:44 -0400 Subject: [PATCH] Add a timeout to background task --- core/external_metadata.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/external_metadata.go b/core/external_metadata.go index e7824e000..8abef8279 100644 --- a/core/external_metadata.go +++ b/core/external_metadata.go @@ -99,7 +99,9 @@ func (e *externalMetadata) UpdateArtistInfo(ctx context.Context, id string, simi // If we have fresh info, just return it and trigger a refresh in the background if time.Since(artist.ExternalInfoUpdatedAt) < consts.ArtistInfoTimeToLive { go func() { - err := e.refreshArtistInfo(context.Background(), artist) + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + err := e.refreshArtistInfo(ctx, artist) if err != nil { log.Error("Error refreshing ArtistInfo", "id", id, "name", artist.Name, err) }