Skip to content

Improve tunnel startup failure handling#89

Draft
Kahiy314 wants to merge 1 commit intoMTDickens:mainfrom
Kahiy314:fix/tunnel-startup-handling
Draft

Improve tunnel startup failure handling#89
Kahiy314 wants to merge 1 commit intoMTDickens:mainfrom
Kahiy314:fix/tunnel-startup-handling

Conversation

@Kahiy314
Copy link
Copy Markdown

@Kahiy314 Kahiy314 commented Apr 8, 2026

The original tunnel bootstrap only waited for a line matching "--rsd HOST PORT". When the underlying pymobiledevice3 command exited early or failed before printing that line, the child process kept reading until the parent hit the 20-second timeout. Different root causes were therefore collapsed into the same generic tunnel failure, which made one-off environment issues hard to diagnose later.

This commit keeps the upstream-facing behavior intact, including the existing 20-second timeout and raw subprocess output, but makes the failure path more explicit and easier to reason about.

Changes:

  • run lockdown start-tunnel in script mode so successful output is easier to parse reliably
  • stop the child read loop when the subprocess exits without emitting an RSD address
  • forward recent subprocess output back to the parent so the real failure reason is visible
  • return early from main.py when tunnel startup fails, instead of continuing with an invalid process/address state
  • terminate the tunnel worker process defensively on failure to avoid leaving it running in the background

The original tunnel bootstrap only waited for a line matching "--rsd HOST PORT".
When the underlying pymobiledevice3 command exited early or failed before
printing that line, the child process kept reading until the parent hit the
20-second timeout. Different root causes were therefore collapsed into the
same generic tunnel failure, which made one-off environment issues hard to
diagnose later.

This commit keeps the upstream-facing behavior intact, including the existing
20-second timeout and raw subprocess output, but makes the failure path more
explicit and easier to reason about.

Changes:
- run lockdown start-tunnel in script mode so successful output is easier to parse reliably
- stop the child read loop when the subprocess exits without emitting an RSD address
- forward recent subprocess output back to the parent so the real failure reason is visible
- return early from main.py when tunnel startup fails, instead of continuing with an invalid process/address state
- terminate the tunnel worker process defensively on failure to avoid leaving it running in the background

Reason:
- improve debugging when tunnel startup fails for transient causes such as permissions, trust state, or device readiness
- avoid cascading follow-up errors after a failed tunnel bootstrap
- keep the change narrow enough to stay suitable for a future upstream PR if needed
@Kahiy314 Kahiy314 marked this pull request as draft April 8, 2026 02:52
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