Skip to content

Commit 15ddc3d

Browse files
authored
fix: pass unwrapped error to backoff/4 when compensate/4 returns bare :retry (#306)
When `compensate/4` returns bare `:retry`, `backoff/4` was receiving the `RunStepError` wrapper instead of the inner error. This was inconsistent with all other code paths, where `backoff/4` receives the unwrapped error.
1 parent 7aaaec4 commit 15ddc3d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/reactor/executor/step_runner.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ defmodule Reactor.Executor.StepRunner do
288288
defp handle_compensate_result(:retry, reactor, step, arguments, context, reason) do
289289
Hooks.event(reactor, :compensate_retry, step, context)
290290

291-
case Step.backoff(step, reason, arguments, context) do
291+
case Step.backoff(step, reason.error, arguments, context) do
292292
delay when is_integer(delay) and delay > 0 -> {:backoff, delay, {:retry, reason}}
293293
_ -> {:retry, reason}
294294
end

test/reactor/executor/step_runner_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ defmodule Reactor.Executor.StepRunnerTest do
242242
Example.Step.Compensable
243243
|> stub(:run, fn _, _, _ -> {:error, :doc} end)
244244
|> stub(:compensate, fn :doc, _, _, _ -> :retry end)
245-
|> stub(:backoff, fn _, _, _, _ -> 100 end)
245+
|> stub(:backoff, fn :doc, _, _, _ -> 100 end)
246246

247247
assert {:backoff, 100, {:retry, %RunStepError{error: :doc}}} =
248248
run(reactor, state, step, nil)

0 commit comments

Comments
 (0)