Skip to content

Commit

Permalink
fix for Infinity delays in Schedule (#2773)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored May 19, 2024
1 parent 9196fff commit 596aaea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/twelve-balloons-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

fix for Infinity delays in Schedule
4 changes: 2 additions & 2 deletions packages/effect/src/internal/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ export const exponential = (
): Schedule.Schedule<Duration.Duration> => {
const base = Duration.decode(baseInput)
return delayedSchedule(
map(forever, (i) => Duration.times(base, Math.min(Number.MAX_SAFE_INTEGER, Math.pow(factor, i))))
map(forever, (i) => Duration.times(base, Math.pow(factor, i)))
)
}

Expand Down Expand Up @@ -1060,7 +1060,7 @@ export const modifyDelayEffect = dual<
const oldStart = Intervals.start(intervals)
const newStart = now + Duration.toMillis(duration)
const delta = newStart - oldStart
const newEnd = Math.min(Math.max(0, Intervals.end(intervals) + delta), Number.MAX_SAFE_INTEGER)
const newEnd = Math.max(0, Intervals.end(intervals) + delta)
const newInterval = Interval.make(newStart, newEnd)
return [state, out, ScheduleDecision.continueWith(newInterval)] as const
})
Expand Down

0 comments on commit 596aaea

Please sign in to comment.