Ido Flax
11/03/2026, 3:18 AMSchedule.delayed and jittered() only change the first pause, every pause after that comes from the original schedule.
import arrow.resilience.Schedule
import arrow.resilience.Schedule.Decision.Continue
import kotlinx.coroutines.runBlocking
import kotlin.time.Duration.Companion.seconds
fun main() = runBlocking {
suspend fun Schedule<Unit, *>.pauses() = buildList {
var step = step
repeat(5) { (step(Unit) as Continue<Unit, *>).also { add(it.delay); step = it.step } }
}
val spaced = Schedule.spaced<Unit>(10.seconds)
println("spaced ${spaced.pauses()}")
println("spaced.delayed { d * 2 } ${spaced.delayed { _, d -> d * 2 }.pauses()}")
println("spaced.jittered() ${spaced.jittered().pauses()}")
println("spaced.mapDecision(* 2) ${spaced.mapDecision { if (it is Continue) Continue(it.output, it.delay * 2, it.step) else it }.pauses()}")
}
spaced [10s, 10s, 10s, 10s, 10s]
spaced.delayed { d * 2 } [20s, 10s, 10s, 10s, 10s]
spaced.jittered() [6.507837879s, 10s, 10s, 10s, 10s]
spaced.mapDecision(* 2) [20s, 20s, 20s, 20s, 20s]
my 🤖 said
The cause is, which hands back the originalDecision.delayedwithout wrapping it:step.Continue(output, transform(output, delay), step),mapandcontramapall wrap the next step.recursiveMap
This also affects `HttpRequestSchedule`’s default,minimal repro attahced, which jitters only its first retry.exponential(2.seconds).jittered()works as expected.mapDecision
Alejandro Serrano.Mena
11/04/2026, 9:36 AMAlejandro Serrano.Mena
11/04/2026, 9:36 AMIdo Flax
11/04/2026, 5:55 PMIdo Flax
11/04/2026, 6:02 PMIdo Flax
11/04/2026, 6:12 PMIdo Flax
11/10/2026, 8:08 PMAlejandro Serrano.Mena
11/11/2026, 8:10 AMIdo Flax
11/11/2026, 8:28 AM