Hacky (temporary, lol) fix for IGDB rate limit errors

This commit is contained in:
grimsi
2025-05-09 23:56:14 +02:00
parent e45585227e
commit 47e69d0d6a
@@ -16,6 +16,7 @@ import org.pf4j.PluginWrapper
import org.slf4j.LoggerFactory
import proto.Game
import java.time.Instant
import java.util.concurrent.TimeUnit
class IgdbPlugin(wrapper: PluginWrapper) : GameyfinPlugin(wrapper) {
@@ -119,6 +120,14 @@ class IgdbPlugin(wrapper: PluginWrapper) : GameyfinPlugin(wrapper) {
return games.map { toGameMetadata(it) }
} catch (e: RequestException) {
// FIXME: Handle rate limit errors with exponential backoff
if (e.statusCode == 429) {
val randomInterval = (1..5).random().toLong()
log.warn("IGDB rate limit exceeded, retrying in $randomInterval seconds...")
TimeUnit.SECONDS.sleep(randomInterval)
return fetchMetadata(gameId, maxResults)
}
log.error("Request to IGDB API failed with HTTP ${e.statusCode}")
}