From 790d681a7d9fa44d616c8a5ebe923df6518920c4 Mon Sep 17 00:00:00 2001 From: James Harton Date: Tue, 7 Apr 2026 09:08:17 +1200 Subject: [PATCH] fix: pass unwrapped error to `backoff/4` when `compensate/4` returns bare `:retry` 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. --- lib/reactor/executor/step_runner.ex | 2 +- test/reactor/executor/step_runner_test.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/reactor/executor/step_runner.ex b/lib/reactor/executor/step_runner.ex index dbc500b..c2a2659 100644 --- a/lib/reactor/executor/step_runner.ex +++ b/lib/reactor/executor/step_runner.ex @@ -288,7 +288,7 @@ defmodule Reactor.Executor.StepRunner do defp handle_compensate_result(:retry, reactor, step, arguments, context, reason) do Hooks.event(reactor, :compensate_retry, step, context) - case Step.backoff(step, reason, arguments, context) do + case Step.backoff(step, reason.error, arguments, context) do delay when is_integer(delay) and delay > 0 -> {:backoff, delay, {:retry, reason}} _ -> {:retry, reason} end diff --git a/test/reactor/executor/step_runner_test.exs b/test/reactor/executor/step_runner_test.exs index 9ce51b2..9abcb27 100644 --- a/test/reactor/executor/step_runner_test.exs +++ b/test/reactor/executor/step_runner_test.exs @@ -242,7 +242,7 @@ defmodule Reactor.Executor.StepRunnerTest do Example.Step.Compensable |> stub(:run, fn _, _, _ -> {:error, :doc} end) |> stub(:compensate, fn :doc, _, _, _ -> :retry end) - |> stub(:backoff, fn _, _, _, _ -> 100 end) + |> stub(:backoff, fn :doc, _, _, _ -> 100 end) assert {:backoff, 100, {:retry, %RunStepError{error: :doc}}} = run(reactor, state, step, nil)