Skip to content

Non-blocking remote/SSH/container backend teardown (#35) - #45

Merged
ElSargo merged 2 commits into
mainfrom
fix/backend-teardown-nonblocking
Sep 16, 2026
Merged

ElSargo merged 2 commits into
mainfrom
fix/backend-teardown-nonblocking

Conversation

@ElSargo

@ElSargo ElSargo commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • disconnect_remote_backend (and related attach failure paths) signal cancel/disconnect on the presentation thread, then join off-loop.
  • SSH/container shutdown uses try_wait with timeout and kill escalation instead of unbounded Child::wait.
  • Completion is delivered as generation-gated ClientEvent::BackendTeardownCompleted.
  • Remit the backend-teardown friction in docs/frictions/ui-concurrency.md.

Fixes #35

Test plan

  • RUSTFLAGS='-C linker=cc' cargo test -p brood-client --lib backend_teardown
  • RUSTFLAGS='-C linker=cc' cargo test -p brood-client --lib remote::
  • Manual: disconnect a hung SSH/container backend; UI should remain responsive while teardown completes.

Residual risks

  • Attach-thread failure paths still call synchronous shutdown() (now timeout-bounded) when the event loop is already closed; those are off the presentation loop.
  • Teardown threads are fire-and-forget aside from the generation-gated completion event; process exit may still race with in-flight joins.

@ElSargo ElSargo left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brood QA (static) — request changes (COMMENT; cannot REQUEST_CHANGES on own PR)

Verdict: Would request changes — one clear doc defect; teardown logic otherwise looks aligned with #35. Please fix before merge.

Blocking

  • docs/frictions/ui-concurrency.md heading corruption after the remittance edit:
    • Got: ### File drop reads### File drop reads and decodes synchronously
    • Want: restore the separate ### File drop reads and decodes synchronously section title (do not splice into the remitted teardown heading).

What looks good (non-blocking once doc fixed)

  • Presentation path signals cancel/disconnect then joins off-loop via spawn_remote_connection_teardown / spawn_child_deployment_teardown.
  • wait_child_with_timeout + kill escalation replaces unbounded Child::wait; unit tests cover reap + hung kill.
  • Completion is generation-gated (pending_backend_teardowns + BackendTeardownCompleted); stale completions no-op.
  • Residuals in PR body (sync shutdown when no proxy / event loop closed; fire-and-forget teardown threads) are acceptable for this remit.

CI

FAILED — GHA Nix ENOSPC. Do not treat as the reason for this review; fix the friction-doc heading regardless.

Stacking

Conflicts expected with #43 on clients/brood-client/src/remote.rs and with the friction-doc stack (#36/#37/#40/#43). Rebase after those land (and after fixing the heading).

Desktop verify: not run.

Signal remote cancel/disconnect on the UI thread, then join the transport
worker and SSH/container children on background teardown threads with
timeout+kill escalation. Gate completion with BackendTeardownCompleted so
stale results cannot mutate newer UI state. Fixes #35.
@ElSargo
ElSargo force-pushed the fix/backend-teardown-nonblocking branch from ccedb3c to 1e0d173 Compare September 16, 2026 22:01
@ElSargo
ElSargo merged commit a23b10b into main Sep 16, 2026
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.

presentation loop blocks on remote reap and SSH/container Child::wait during backend teardown

1 participant