stacklok / stacklok/toolhive

thv: Stop on a Foreground Process Removes the Workload

Open
#2,950 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug cli
Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

Bug description

Running thv stop on a workload started by thv run --foreground causes the workload to be removed from thv list --all results.

This is perceived as a bug, because stop is effectively acting as rm.

Steps to reproduce

  1. thv run --foreground --name fetch-foreground fetch
  2. In another shell: thv stop fetch-foreground
  3. Observe thv list --all does not contain fetch-foreground

Expected behavior

There are multiple acceptable behaviors:

  • thv stop cannot be run on foreground workloads
  • thv stop does not remove the state for the foreground workload, but stops it. In other words, thv list --all contains fetch-foreground and it is in a stopped status.

Actual behavior

thv stop behaves like thv rm when executed against foreground workloads.

Environment (if relevant)

  • OS/version: Mac Version 15.4.1
  • ToolHive version: v0.6.11-42-g2b6a4a76

Additional context

This PR contains significant prior art: https://github.com/stacklok/toolhive/pull/2927#pullrequestreview-3553421250

The problem is the --foreground process acts as the owner of the workload and will always remove the workload when it exits. This can be seen in the logs below:

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the lifecycle with thv run --foreground --name fetch-foreground fetch, then run thv stop fetch-foreground and inspect thv list --all. Read the prior art in PR #2927 and trace how the foreground owner handles exit. Done means stop either rejects foreground workloads or leaves them listed with a stopped status.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.