Skip to content

fix: Handle named ancestors in Tesla.Mock#774

Merged
yordis merged 1 commit intoelixir-tesla:masterfrom
grain-team:howleysv/named-ancestors
Jun 2, 2025
Merged

fix: Handle named ancestors in Tesla.Mock#774
yordis merged 1 commit intoelixir-tesla:masterfrom
grain-team:howleysv/named-ancestors

Conversation

@howleysv
Copy link
Copy Markdown
Contributor

The process $ancestor list can contain named processed as well as pids in certain supervision tree structures. This PR fixes a crash that happens with Tesla.Mock when a mocked module is called from within a spawned task within a named supervision tree, by looking up the pid of the named process if it exists.

Here is a trivial example showing the problematic $ancestors behaviour that causes the error

iex(1)> Supervisor.start_link([{Task.Supervisor, name: MyTaskSup}], [name: MySup, strategy: :one_for_one])
{:ok, #PID<0.109.0>}
iex(2)> Task.Supervisor.async(MyTaskSup, fn -> :erlang.get(:"$ancestors") end) |> Task.await()
[#PID<0.110.0>, MySup, #PID<0.108.0>, #PID<0.98.0>]

@yordis yordis merged commit 6cf380e into elixir-tesla:master Jun 2, 2025
6 checks passed
@yordis
Copy link
Copy Markdown
Member

yordis commented Jun 2, 2025

🚀 💜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants