safwank / ElixirRetry

Simple Elixir macros for linear retry, exponential backoff and wait with composable delays
Other
441 stars 32 forks source link

Arithmetic error when taking many values from a stream #25

Closed axelson closed 5 years ago

axelson commented 6 years ago

Code that reproduces the issue on retry 0.10:

iex(18)> Retry.DelayStreams.exp_backoff(100) |> Retry.DelayStreams.cap(30_000) |> Enum.take(10_000)
** (ArithmeticError) bad argument in arithmetic expression
    (retry) lib/retry/delay_streams.ex:22: anonymous fn/2 in Retry.DelayStreams.exp_backoff/1
    (elixir) lib/stream.ex:1466: Stream.do_unfold/4
    (elixir) lib/stream.ex:1536: Enumerable.Stream.do_each/4
    (elixir) lib/enum.ex:2423: Enum.take/2

I usually won't be taking 10_000 elements from the stream but it seems possible that with other stream compositions this could happen sooner.

safwank commented 6 years ago

@axelson Thanks for reporting this.

safwank commented 5 years ago

Fixed in v0.11.1.