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 all commits
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`, the test process will be linked to the
> spawned processes. When the test process exits, it exits with reason `:shutdown`,
> and the crash signal propagates to all linked processes virtually simultaneously,
> which can lead to processes terminating in an unpredictable order if they are not
> trapping exits. 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`. This way the
> test process exiting does not affect the started processes, and they will be 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