Swarm stops to respond when try to find name
- Dominant language
- Elixir
- Stars
- 1.3k
- Forks
- 110
- PR merge metrics
- No merged PRs in 30d
Description
If you try to run `Swarm.whereis_name(name)` while `Swarm.register_name(name, Sup....)` didn't finish yet, the application stops to respond.
```elixir
defmodule MyDynamicSupervisor do
use DynamicSupervisor
# Initialization
def register(name) do
child_spec = %{
id: MyActor,
start: {MyActor, :start_link, [name]},
restart: :transient
}
case DynamicSupervisor.start_child(__MODULE__, child_spec) do
{:error, {:already_started, pid}} -> {:ok, pid}
{:ok, pid} -> {:ok, pid}
end
end
end
```
```elixir
defmodule MyActor do
use GenServer
def start_actor(name) do
{:ok, pid} = Swarm.register_name(name, MyDynamicSupervisor, :register, [name])
end
def start_link(name) do
GenServer.start_link(__MODULE__, name)
end
def init(name) do
pid = Swarm.whereis_name(name) # At this moment, the application stops to respond
{:ok, name}
end
end
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the issue with the provided MyDynamicSupervisor and MyActor example, focusing on Swarm.register_name and Swarm.whereis_name during child initialization. Trace the registration and lookup behavior when registration has not completed, then verify that the application remains responsive and that name lookup returns an appropriate result instead of blocking indefinitely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100