Skip to content

Commit 7be9e77

Browse files
committed
fix: suspend leak test accepts both failure payload shapes
1 parent bf49c52 commit 7be9e77

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

test/continuum/runtime/suspend_leak_test.exs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ defmodule Continuum.Runtime.SuspendLeakTest do
3535
assert_received {:flow, flow}
3636
{:ok, run_id} = Continuum.Test.start_synchronous(flow, %{})
3737

38-
assert {:error, %{state: :failed, error: {:error, %Continuum.SuspendLeakError{} = error}}} =
39-
Continuum.await(run_id, 1_000)
40-
38+
assert {:error, %{state: :failed, error: failure}} = Continuum.await(run_id, 1_000)
39+
assert %Continuum.SuspendLeakError{} = error = leak_error(failure)
4140
assert Exception.message(error) =~ "suspend signal was swallowed"
4241
assert Exception.message(error) =~ "rescue"
4342
end
@@ -64,10 +63,17 @@ defmodule Continuum.Runtime.SuspendLeakTest do
6463
assert_received {:flow, flow}
6564
{:ok, run_id} = Continuum.Test.start_synchronous(flow, %{})
6665

67-
assert {:error, %{state: :failed, error: {:error, %Continuum.SuspendLeakError{}}}} =
68-
Continuum.await(run_id, 1_000)
66+
assert {:error, %{state: :failed, error: failure}} = Continuum.await(run_id, 1_000)
67+
assert %Continuum.SuspendLeakError{} = leak_error(failure)
6968
end
7069

70+
# `await` resolves the failure from either the engine's `run_finished`
71+
# broadcast ({:error, exception}) or the journal row ({kind, reason,
72+
# stacktrace}), depending on which side wins the subscribe race.
73+
defp leak_error({:error, %Continuum.SuspendLeakError{} = error}), do: error
74+
defp leak_error({:error, %Continuum.SuspendLeakError{} = error, _stacktrace}), do: error
75+
defp leak_error(other), do: other
76+
7177
test "a catch arm that re-throws the control tuple suspends normally" do
7278
capture_io(:standard_error, fn ->
7379
defmodule RethrowFlow do

0 commit comments

Comments
 (0)