[Bug]: Registry server crashes when the update checker writes last_update after the registry was closed
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
Direzione di ricerca
Leggi gli handler :close e :last_update in lib/hex/registry/server.ex, poi segui la chiamata da lib/hex/update_checker.ex e le chiamate a :close in lib/mix/tasks/hex.package.ex. Verifica come si comporta l’handler quando lo stato del registro contiene ets: nil. Il lavoro è terminato quando una scrittura tardiva di last_update viene ignorata senza causare l’arresto anomalo del registro; aggiungi o aggiorna un test per questo caso.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Product or component
hexpm/hex: Package manager client CLI and Mix task integration for Erlang/Elixir
Summary
The update checker's last_update write can reach a registry that its task already closed. handle_call({:last_update, time}, ...) then runs :ets.insert(nil, ...) and the registry server crashes. This is the crash in #936 and #996, both closed as not reproducible; below is the cause.
What happened?
Opening the registry casts Hex.UpdateChecker.start_check/0 (lib/hex/registry/server.ex, the :open handlers), which starts an async request for the Hex installs list. When it returns, Hex.UpdateChecker.handle_info/2 calls Hex.Registry.Server.last_update/1 (lib/hex/update_checker.ex, line 76).
Some tasks close the registry themselves before that request returns, for example mix hex.package fetch (lib/mix/tasks/hex.package.ex, the Hex.Registry.Server.close() calls). After :close the state has ets: nil, and lib/hex/registry/server.ex line 439 runs :ets.insert(state.ets, {:last_update, time}), which crashes the server. A caller waiting on the registry, such as a later close/0, receives that crash as an exit.
Because the write never lands, last_update is never saved, so a fresh HEX_HOME (for example in CI) runs the update check, and can hit this crash, on every command. In our CI it failed 2 of 2 runs on 2026-11-08.
What did you expect?
A last_update write after the registry was closed should be ignored, not crash the registry.
Steps to reproduce
- Use an empty
HEX_HOME. - Run
mix hex.package fetch <package> <version>repeatedly. - It crashes whenever the installs request returns after the task's own registry close. The timing varies; #936 shows the same crash from
mix archive.install hex phx_newand #996 fromMix.install/1.
Environment / context
- Hex 2.6.0; the same code is on
main(2.8.0-dev, 986d4e6) - Elixir 1.20.4, Erlang/OTP 29.1.2
- Linux, x86_64
Logs / screenshots
GenServer Hex.Registry.Server terminating
** (ArgumentError) errors were found at the given arguments:
* 1st argument: the table identifier does not refer to an existing ETS table
(stdlib) :ets.insert(nil, {:last_update, {{2026, 11, 8}, {15, 7, 42}}})
(hex 2.6.0) lib/hex/registry/server.ex:439: Hex.Registry.Server.handle_call/3
Last message (from Hex.UpdateChecker): {:last_update, {{2026, 11, 8}, {15, 7, 42}}}
State: %{ets: nil, ...}
Additional context
Possible fix: ignore the write when the registry is closed, for example
def handle_call({:last_update, _time}, _from, %{ets: nil} = state) do
{:reply, :ok, state}
end
or have the update checker skip last_update/1 when the registry is not open.
- Lingua principale
- Elixir
- Stelle
- 1.1k
- Fork
- 214
- Merge medio
- 16h 50m
- PR unite (30g)
- 38
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hexpm/hex
-
[Bug]: Registry requests time out under load because 32 parallel fetches share 8 httpc connectionsAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
Start :ssl/:inets lazily: ~20ms on every Mix command that loads Hex depsForse già presa @onnimonni l’ha presa 6 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 50/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
hexpm/hex#1188 · 1 commento · 3 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Kind:Feature Note:Discussion
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
semaphoreio/semaphore#1391 ·
I maintainer di solito rispondono entro 1 giorno
-
agent-ready area:skills
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
jmbarzee/temporal-architect#588 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
intellij-elixir/intellij-elixir#4659 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
getsentry/sentry-elixir#1259 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
[Bug]: PostgreSQL backend: Queue.remove() / Job.remove() never emit the QueueEvents "removed" eventForse già presa @1AbdullahButt l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
taskforcesh/bullmq#5085 ·
I maintainer di solito rispondono entro 1 giorno