Skip to content

fix: start the client without -skipselect, which races the join on tModLoader 1.4.5 - #117

Merged
musharna merged 2 commits into
masterfrom
fix/join-without-skipselect
Nov 16, 2026
Merged

musharna merged 2 commits into
masterfrom
fix/join-without-skipselect

Conversation

@musharna

@musharna musharna commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Outcome

  • launch and join start the client with -join 127.0.0.1 -port <port> -player <name> and no -skipselect.
  • On tModLoader 1.4.5 the flag, next to -join, also loads the first local world and enters it. That load raced the join. When it landed first the server kicked the client with "Invalid operation at this state" and the call waited out its full timeout. Issue 108 reports this at about 2 launches in 10 on 1.4.5.8, with the decompiled cause and this fix.

Run against a live game

The reporter ran it on 1.4.5.8 (6 of 6 scripted launches joined, one "Entering world" per client). The open question was 1.4.4.9, which the live checks in this repo run against: does -join -player select the character there without -skipselect? It does. On 2026-11-16 tests/live_capture_check.py ran from this branch (b65a703) on tModLoader 1.4.4.9+2026.09.3.1: the server started, both clients (launch and join, each through _client_join_cmd) entered the world and reported ready, 3 of 3 capture rounds passed, exit 0, and a captured frame shows the character in the world. One launch and one join: it shows the flag is not needed on 1.4.4.9, not how often a join succeeds. Run on a second install, with the template mod (template/DevBridgeTemplate) as the only mod.

Acceptance check

uv run pytest -q                      # exit 0
uv run python tests/live_capture_check.py   # on a machine with the game, 1.4.4.9: exit 0, 3/3 rounds (2026-11-16)
  • Two new tests compare the whole client command, one for launch and one for join. Seen to fail through mutate-run with the flag put back: both fail on Left contains one more item: '-skipselect' (1 of 1 killed). Each also asserts the legitimate path completed (two spawns recorded for launch; session.joined == ["tst2"] for join).

Constraints

  • No tool, parameter or output changes.
  • The readiness rules are untouched: join still waits for the tokened heartbeat only.
  • NO_HEADLESS_SINGLEPLAYER and the README sentence about it still name -skipselect. They record what was measured for singleplayer with that flag, which this PR does not re-measure.

Risk and revert

  • The 1.4.4.9 risk (a client left at the character menu) did not happen in the live run above. Not measured: the join rate over many launches on either version here.
  • Revert is git revert. Both callers now build the command in _client_join_cmd, so a per-version flag, if one turns out to be needed, goes in one place.

On tModLoader 1.4.5, -skipselect next to -join also loads the first local
world and enters it in singleplayer. That load raced the network join; when
it landed first the server booted the client with "Invalid operation at this
state" and launch/join waited out the full timeout (issue 108, about 2
launches in 10 on 1.4.5.8).

launch and join each built the client command from their own copy of the
list. Both now call _client_join_cmd, and a test for each caller compares
the whole command. tests/live_race_check.py uses the same builder.

Not yet run against a live game on 1.4.4.9.
@claude

claude Bot commented Nov 13, 2026

Copy link
Copy Markdown

Nothing meets the bar.

Reviewed the whole diff (session.py, both call sites in launch/join, tests/live_race_check.py, and the new tests in tests/test_session_lifecycle.py).

  • _client_join_cmd is used identically by both launch and join; no leftover copy of the old -skipselect-bearing list remains anywhere, including tests/live_race_check.py.
  • The one surviving -skipselect reference, NO_HEADLESS_SINGLEPLAYER (session.py:127-138), documents a separate, already-measured fact about singleplayer and is correctly out of scope per the PR's stated constraints.
  • The new tests have real positive and negative controls: _recorded_spawns wraps the already-installed fake Popen (rather than replacing it), so it records the exact argv launch/join pass to subprocess.Popen, and the expected command list (_join_cmd in the test file) is written independently of _client_join_cmd rather than imported from it — so the test can actually fail if the production list regresses, not just echo it back.
  • test_launch_starts_its_client_with_join_and_player_and_nothing_else also checks that exactly two processes are spawned and that the first (server) command has no -join, which guards against the client/server command lists getting swapped.
  • test_a_join_starts_its_client_with_join_and_player_and_nothing_else asserts session.joined == ["tst2"] as the positive control alongside the command-list check, so the test can't pass on a join that never completed.

@musharna
musharna marked this pull request as ready for review November 16, 2026 06:41
@musharna
musharna merged commit 9e8ffb2 into master Nov 16, 2026
9 checks passed
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