Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning to the docs for start_link_supervised!/2 #14374

Merged
merged 2 commits into from
Mar 28, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/ex_unit/lib/ex_unit/callbacks.ex
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,19 @@ defmodule ExUnit.Callbacks do

Note that if the started process terminates before it is linked to the test process,
this function will exit with reason `:noproc`.

> #### To Link or Not To Link {: .warning}
>
> When using `start_link_supervised!/2`, be aware that the order of process termination
> during test exit is not guaranteed (for the processes started with
> `start_link_supervised!/2`). When the test process exits, the crash signal propagates
> to all linked processes virtually simultaneously, which can lead to processes
> terminating in an unpredictable order. This is particularly problematic when you have
> processes that the test starts with `start_link_supervised!/2` and that depend on
> each other.
>
> If you need guaranteed shutdown order, use `start_supervised/2`. With that, processes
> are shut down *by the test supervisor* in reverse order, ensuring graceful termination.
"""
@doc since: "1.14.0"
@spec start_link_supervised!(Supervisor.child_spec() | module | {module, term}, keyword) ::
Expand Down
Loading