Skip to content

bug: runGit and ghFetchIssue have no timeout, can hang indefinitely #47

@claude

Description

@claude

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.go lines 79-87
  • internal/project/workingmemory.go lines 128-147
  • Callers: GetWorkingMemory, Detect, defaultBranch

@claude please implement this

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions