fix: stop stale request retries

This commit is contained in:
2026-06-18 20:25:30 +02:00
committed by Milas Holsting
parent aed61b8b61
commit 9e0f2231b5
5 changed files with 50 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ package jikan
import (
"context"
"encoding/json"
"errors"
"fmt"
"reflect"
"sync"
@@ -98,6 +99,10 @@ func jikanCacheLogLevel(source string, err error) observability.LogLevel {
}
func (c *Client) logJikanCache(cacheKey string, source string, startedAt time.Time, err error) {
if isContextError(err) {
return
}
duration := time.Since(startedAt)
if c.shouldSkipJikanCacheLog(source, duration, err) {
return
@@ -125,6 +130,10 @@ func truncateErrorMessage(message string) string {
return message[:400]
}
func isContextError(err error) bool {
return errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded)
}
// notifyRetryWorker signals the retry worker, non-blocking.
func (c *Client) notifyRetryWorker() {
select {