MOB-69 — mix mob.connect --name is honored end-to-end - #84
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
--nameoption was parsed at the Mix-task layer but silently ignored downstream.Trace of the bug
mob.connect.ex:141reads--name→local_name.mob.connect.ex:159callsConnector.connect_all/1WITHOUT:name.connector.ex:220ensure_local_dist/1hardcodesNode.start(:"mob_dev@127.0.0.1", :longnames).mob.connect.ex:169then callsstart_iex(connected, cookie, local_name).mob.connect.ex:214unless Node.alive?()— already true — so itsNode.start(local_name, ...)never runs.Result:
--name mob_dev_2@127.0.0.1silently registeredmob_dev@127.0.0.1in EPMD. The documented multi-session workflow (one--name mob_dev_Nper developer, from the task's moduledoc) crashed.Fix
:namethroughConnector.connect_all/1into a newensure_local_dist/2.Connector.local_name_from_opts/1so the option-plumbing has a unit-testable seam (returns default when unset, accepts atom or string).mob.connect.expassesname: local_nameintoconnect_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/1consulting 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 greenmix credo --strict: 0 issuesmix compile --warnings-as-errors --force: cleanCloses MOB-69.