Skip to content

MOB-69 — mix mob.connect --name is honored end-to-end - #84

Merged
GenericJam merged 1 commit into
masterfrom
fix/MOB-69-connect-name
Sep 12, 2026
Merged

GenericJam merged 1 commit into
masterfrom
fix/MOB-69-connect-name

Conversation

@GenericJam

Copy link
Copy Markdown
Owner

The --name option was parsed at the Mix-task layer but silently ignored downstream.

Trace of the bug

  1. mob.connect.ex:141 reads --namelocal_name.
  2. mob.connect.ex:159 calls Connector.connect_all/1 WITHOUT :name.
  3. connector.ex:220 ensure_local_dist/1 hardcodes Node.start(:"mob_dev@127.0.0.1", :longnames).
  4. mob.connect.ex:169 then calls start_iex(connected, cookie, local_name).
  5. mob.connect.ex:214 unless Node.alive?() — already true — so its Node.start(local_name, ...) never runs.

Result: --name mob_dev_2@127.0.0.1 silently registered mob_dev@127.0.0.1 in EPMD. The documented multi-session workflow (one --name mob_dev_N per developer, from the task's moduledoc) crashed.

Fix

  • Thread :name through Connector.connect_all/1 into a new ensure_local_dist/2.
  • Extract a public Connector.local_name_from_opts/1 so the option-plumbing has a unit-testable seam (returns default when unset, accepts atom or string).
  • mob.connect.ex passes name: local_name into connect_all.

Default preserved: no-arg calls still get :"mob_dev@127.0.0.1".

Tests

Three tests on local_name_from_opts/1 (default, atom, string). The call-site swap (connect_all/1 consulting the helper) is manual-verify — testing the actual Node.start path requires mocking BEAM-level distribution, which the test suite doesn't currently do. Diff is small enough that the call-site swap is obvious on review.

Gates

  • mix test: 15 pass on connector_test.exs (+3 new), full suite green
  • mix credo --strict: 0 issues
  • mix compile --warnings-as-errors --force: clean

Closes MOB-69.

The option was parsed at the Mix-task layer, but the flow was:

1. `mob.connect` reads `--name` (line 141) → `local_name`.
2. `mob.connect` calls `Connector.connect_all/1` WITHOUT passing name.
3. `connect_all/1` calls `ensure_local_dist/1` which hardcodes
   `Node.start(:"mob_dev@127.0.0.1", :longnames)`.
4. `mob.connect` then calls `start_iex(connected, cookie, local_name)`.
5. `start_iex` checks `unless Node.alive?()` — already true — so its
   `Node.start(local_name, ...)` never runs.

Result: `--name mob_dev_2@127.0.0.1` silently registered
`mob_dev@127.0.0.1` in EPMD, breaking the documented multi-session
workflow (two developers on the same box couldn't each have their own
IEx into different device clusters — the second one hit "node already
started" or connected to the first one's cluster).

Fix: thread `:name` through `connect_all/1` into a new
`ensure_local_dist/2`, backed by a public `local_name_from_opts/1`
helper so the option-plumbing is unit-testable. Default preserved.

Three tests on the helper's contract (default, atom, string). The
call-site flow (that `connect_all/1` actually consults the helper) is
manual-verify — testing the Node.start path requires mocking BEAM-level
distribution which we don't do here. Small change; commit message +
diff make the call-site swap obvious.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@GenericJam
GenericJam merged commit 7a6f215 into master Sep 12, 2026
3 checks passed
@GenericJam
GenericJam deleted the fix/MOB-69-connect-name branch September 12, 2026 05:37
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.

1 participant