-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Bug
runGit (internal/project/project.go:79-87) and ghFetchIssue (internal/project/workingmemory.go:128-147) execute shell commands with no timeout:
// internal/project/project.go:79-87
func runGit(dir string, args ...string) (string, error) {
cmd := exec.Command("git", args...)
cmd.Dir = dir
out, err := cmd.Output() // blocks forever if git hangs
...
}
// internal/project/workingmemory.go:128-131
func ghFetchIssue(wm *WorkingMemory, issueNumber int) {
cmd := exec.Command("gh", "issue", "view", ...)
out, err := cmd.Output() // blocks forever if gh hangs
...
}GetWorkingMemory is called synchronously in runHandler (before the API fetch) and pregenHandler. Git commands can block indefinitely on network operations (e.g. git remote get-url with a slow/broken network, or git log on a pathological repo). gh issue view can also block waiting for the GitHub API. A hung git/gh call silently hangs the entire uncompact run hook.
Fix
Pass a context.Context with a short deadline (e.g. 5 s) to both helpers via exec.CommandContext, so they are cancelled if the operation takes too long. The callers (GetWorkingMemory, Detect) should accept and thread a context through.
Affected files:
internal/project/project.golines 79-87internal/project/workingmemory.golines 128-147- Callers:
GetWorkingMemory,Detect,defaultBranch
@claude please implement this