Skip to content

Add timeouts to all daemon socket operations #12

@joelhooks

Description

@joelhooks

Problem

Currently daemon client operations may hang indefinitely if the daemon is stuck or unresponsive. This makes the CLI fragile for agentic use.

Pattern from Go CLI Books

From "Building Modern CLI Applications in Go" and "Powerful Command-Line Applications in Go":

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

result, err := client.Lease(ctx, secretName)
if errors.Is(err, context.DeadlineExceeded) {
    return fmt.Errorf("daemon unresponsive (timeout after 5s)")
}

Action Items

  • Audit all socket operations in internal/daemon/
  • Add context.WithTimeout to all RPC calls
  • Add --timeout flag to CLI for user override
  • Return specific exit code for timeout (65)

Book References

  • Search: pdf-brain search "timeout context deadline" --fts --expand 2000
  • Search: pdf-brain search "graceful shutdown signal" --fts --expand 2000

Priority

P0 - Critical for robust agentic use

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions