fix(chat): don't report a stopped answer as running #37

Manually merged
jfro merged 1 commit from fix/24-chat-stop-race into main 2026-11-01 21:03:19 +00:00
Owner

Fixes the chat_test flake (finding F19).

Chat.running/1, Chat.stop/1 and the runner's registered_pid/1 used Registry.lookup, which keeps returning a terminated runner's entry until the Registry partition has handled the EXIT. Task.Supervisor.terminate_child is synchronous but that cleanup isn't, so right after a stop running/1 could still return the answer (the assert Chat.running(conversation.id) == nil flake, and briefly a stopped answer shown as running in the chat pane). A private lookup/1 now drops dead pids. Re-registering was already fine.

Root cause and patch from Nye.

  • Probe (Registry partitions suspended around the stop): main 200/200 stale, this branch 0/200
  • mix test test/lamplighter/chat_test.exs --repeat-until-failure 400: 401 runs, all pass
  • mix precommit: 801 passed

Closes #24

Fixes the chat_test flake (finding F19). `Chat.running/1`, `Chat.stop/1` and the runner's `registered_pid/1` used `Registry.lookup`, which keeps returning a terminated runner's entry until the Registry partition has handled the EXIT. `Task.Supervisor.terminate_child` is synchronous but that cleanup isn't, so right after a stop `running/1` could still return the answer (the `assert Chat.running(conversation.id) == nil` flake, and briefly a stopped answer shown as running in the chat pane). A private `lookup/1` now drops dead pids. Re-registering was already fine. Root cause and patch from Nye. - Probe (Registry partitions suspended around the stop): main 200/200 stale, this branch 0/200 - `mix test test/lamplighter/chat_test.exs --repeat-until-failure 400`: 401 runs, all pass - `mix precommit`: 801 passed Closes #24
jfro added this to the v1.0 milestone 2026-11-01 20:39:11 +00:00
fix(chat): don't report a stopped answer as running
All checks were successful
CI / test (pull_request) Successful in 26s
56c4275b39
Registry.lookup keeps a terminated runner's entry until the Registry
partition handles the EXIT, so Chat.running/1 could still return an
answer right after Chat.stop/1. Skip dead pids in Runner's lookup.

Closes #24
jfro manually merged commit 3f083d1d7d into main 2026-11-01 21:03:19 +00:00
Sign in to join this conversation.
No description provided.