Skip to content

Local apps should terminate themselves when dropped#78

Merged
bradhe merged 1 commit intodevelopfrom
fixes/terminate-apps-on-drop
Aug 13, 2025
Merged

Local apps should terminate themselves when dropped#78
bradhe merged 1 commit intodevelopfrom
fixes/terminate-apps-on-drop

Conversation

@bradhe
Copy link
Contributor

@bradhe bradhe commented Aug 12, 2025

Sometimes we end up with orphaned or zombied apps, despite our best efforts. This PR tries to be more aggressive about getting rid of zombie apps in the event of a failure.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements automatic termination of local applications to prevent orphaned or zombie processes. It adds defensive cleanup mechanisms by setting kill_on_drop(true) on UV processes and implementing a Drop trait for LocalApp that calls terminate() when the app is dropped.

  • Added kill_on_drop(true) to all UV command executions
  • Implemented Drop trait for LocalApp to automatically terminate processes on cleanup

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/tower-uv/src/lib.rs Added kill_on_drop(true) to four UV command invocations to ensure child processes are terminated when dropped
crates/tower-runtime/src/local.rs Implemented Drop trait for LocalApp to call terminate() when the app instance is dropped

impl Drop for LocalApp {
fn drop(&mut self) {
// We want to ensure that we cancel the process if it is still running.
let _ = self.terminate();
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

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

Silently ignoring the result of terminate() may hide important errors. Consider logging the error or at least adding a comment explaining why the error is intentionally ignored.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@socksy socksy left a comment

Choose a reason for hiding this comment

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

Confused why "kill_on_drop" isn't the default. Docs say it's because it's the case in the standard library... but why is that so?

@bradhe bradhe merged commit 4406b50 into develop Aug 13, 2025
4 checks passed
@bradhe bradhe deleted the fixes/terminate-apps-on-drop branch August 13, 2025 07:31
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.

3 participants