Skip to content

Commit d5733cc

Browse files
committed
Add warning to the docs for start_link_supervised!/2
1 parent 7b71138 commit d5733cc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/ex_unit/lib/ex_unit/callbacks.ex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,19 @@ defmodule ExUnit.Callbacks do
612612
613613
Note that if the started process terminates before it is linked to the test process,
614614
this function will exit with reason `:noproc`.
615+
616+
> #### To Link or Not To Link {: .warning}
617+
>
618+
> When using `start_link_supervised!/2`, be aware that the order of process termination
619+
> during test exit is not guaranteed (for the processes started with
620+
> `start_link_supervised!/2`). When the test process exits, the crash signal propagates
621+
> to all linked processes virtually simultaneously, which can lead to processes
622+
> terminating in an unpredictable order. This is particularly problematic when you have
623+
> processes that the test starts with `start_link_supervised!/2` and that depend on
624+
> each other.
625+
>
626+
> If you need guaranteed shutdown order, use `start_supervised/2`. With that, processes
627+
> are shut down *by the test supervisor* in reverse order, ensuring graceful termination.
615628
"""
616629
@doc since: "1.14.0"
617630
@spec start_link_supervised!(Supervisor.child_spec() | module | {module, term}, keyword) ::

0 commit comments

Comments
 (0)