From 4c7df9d302d6f5e653bda6c29e711b8e3400cb18 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Wed, 15 Apr 2026 00:26:18 -0400 Subject: [PATCH] fix(subscriptions): avoid races in teardown assertions Signed-off-by: Yordis Prieto --- test/subscriptions/subscriptions_test.exs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/subscriptions/subscriptions_test.exs b/test/subscriptions/subscriptions_test.exs index 975af0e6..d7845581 100644 --- a/test/subscriptions/subscriptions_test.exs +++ b/test/subscriptions/subscriptions_test.exs @@ -23,13 +23,12 @@ defmodule Commanded.SubscriptionsTest do end test "should not remove PID when process terminates" do - pid = - spawn_link(fn -> + {pid, ref} = + spawn_monitor(fn -> :ok = Subscriptions.register(DefaultApp, "handler1", Handler1, :strong) end) - ref = Process.monitor(pid) - assert_receive {:DOWN, ^ref, :process, _, :normal} + assert_receive {:DOWN, ^ref, :process, ^pid, :normal} assert Subscriptions.all(DefaultApp) == [{"handler1", Handler1, pid}] end