fix(jikan): decode response body before closing on final attempt

This commit is contained in:
2026-04-22 10:49:15 +02:00
parent 621d4e1bf1
commit 157c3b97a2

View File

@@ -291,9 +291,8 @@ func (c *Client) fetchWithRetry(ctx context.Context, urlStr string, out any) err
retryAfter = parsed
}
resp.Body.Close()
if retryable && attempt < maxRetries-1 {
resp.Body.Close()
delay := retryDelay(attempt)
if retryAfter > delay {
delay = retryAfter
@@ -306,6 +305,12 @@ func (c *Client) fetchWithRetry(ctx context.Context, urlStr string, out any) err
continue
}
err = json.NewDecoder(resp.Body).Decode(out)
resp.Body.Close()
if err == nil {
return nil
}
return apiErr
}