1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-10-05 19:31:01 +00:00

feat(feed): use exponential backoff for broken feeds

Instead of having a hard limit of 3 (regular) tries for feeds with errors, use
an exponential backoff by default, with an upper-limit of one week.

See https://github.com/miniflux/v2/issues/3334 for context/discussions.
This commit is contained in:
jvoisin 2025-09-30 16:44:36 +02:00
parent 8adcaed29e
commit 63b1279792
4 changed files with 16 additions and 5 deletions

View file

@ -6,6 +6,7 @@ package model // import "miniflux.app/v2/internal/model"
import (
"fmt"
"io"
"math"
"time"
"miniflux.app/v2/internal/config"
@ -135,6 +136,16 @@ func (f *Feed) ScheduleNextCheck(weeklyCount int, refreshDelay time.Duration) ti
// Use the RSS TTL field, Retry-After, Cache-Control or Expires HTTP headers if defined.
interval = max(interval, refreshDelay)
// Use a binary exponential backoff for feeds with parsing errors.
// https://en.wikipedia.org/wiki/Exponential_backoff
if f.ParsingErrorCount > 0 {
backoff := time.Duration(math.Pow(2, float64(f.ParsingErrorCount))) * time.Hour
// Set a hard limit at one week
if backoff.Hours() < time.Hour.Hours()*24*7 {
interval += backoff
}
}
// Limit the max interval value for misconfigured feeds.
switch config.Opts.PollingScheduler() {
case SchedulerRoundRobin: