Skip to content

Commit e7555da

Browse files
authored
Fix unregistration crash (#10326)
1 parent 98cfa7b commit e7555da

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/elixir/lib/registry.ex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,8 @@ defmodule Registry do
261261
end
262262

263263
@doc false
264-
def unregister_name({registry, key}) do
265-
unregister(registry, key)
266-
end
264+
def unregister_name({registry, key}), do: unregister(registry, key)
265+
def unregister_name({registry, key, _value}), do: unregister(registry, key)
267266

268267
## Registry API
269268

lib/elixir/test/elixir/registry_test.exs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,13 @@ defmodule RegistryTest do
863863
end
864864
end
865865

866+
test "unregistration on crash with {registry, key, value} via tuple", %{registry: registry} do
867+
name = {:via, Registry, {registry, :name, :value}}
868+
spec = %{id: :foo, start: {Agent, :start_link, [fn -> raise "some error" end, [name: name]]}}
869+
assert {:error, {error, _childspec}} = start_supervised(spec)
870+
assert {%RuntimeError{message: "some error"}, _stacktrace} = error
871+
end
872+
866873
defp register_task(registry, key, value) do
867874
parent = self()
868875

0 commit comments

Comments
 (0)