Skip to content

Don't lose the adb failure reason to the stdout/stderr close race - #59

Merged
laomou merged 1 commit into
mainfrom
fix/adb-stderr-race
Aug 6, 2026
Merged

Don't lose the adb failure reason to the stdout/stderr close race#59
laomou merged 1 commit into
mainfrom
fix/adb-stderr-race

Conversation

@laomou

@laomou laomou commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Summary

has_ended flips when adb's stdout closes, but the UI read stderr_text() and dropped the session in the same breath — while the separate stderr thread might not have finished draining yet. So a session that died with a reason (device offline, unknown command, "more than one device") often showed a bare "adb ended" and discarded the reason permanently.

Add Session::reap(): wait on the already-exited child and join the stderr worker so the captured stderr is complete before it is read (unlike stop(), it doesn't kill — the process already exited). The UI reaps the session before reading the reason.

Also (drive-by test fix)

The config tests added in the persistence PR were flaky: tempdir_new() handed out a shared directory, and ini_migration_reads_main_ini's remove_dir_all() could wipe it while parallel file-based tests were mid-run. Each call now gets a unique dir. (Surfaced locally when the new adb test shifted thread timing.)

Test plan

  • reap_drains_stderr_of_a_self_ended_session — after a self-ended session, reap() joins the stderr worker and stderr_text() returns the full reason
  • Full suite run 3× — 119 pass every time (was intermittently 2 failing)
  • clippy clean

`has_ended` flips when adb's *stdout* closes, but the UI read `stderr_text()`
and dropped the session in the same breath — while the separate stderr thread
might not have finished draining. So a session that died with a reason (device
offline, unknown command, "more than one device") often showed a bare
"adb ended" and discarded the reason for good.

Add Session::reap(): wait on the already-exited child and join the stderr
worker so the captured stderr is complete before it's read. The UI reaps the
session before reading the reason.

Also fix flaky config tests (from the persistence PR): tempdir_new() handed out
a shared directory that ini_migration_reads_main_ini's remove_dir_all() could
wipe while parallel file-based tests were mid-run — give each call a unique dir.
@laomou
laomou merged commit e97c41e into main Aug 6, 2026
5 of 6 checks passed
@laomou
laomou deleted the fix/adb-stderr-race branch August 6, 2026 12:54
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