Skip to content

[Feature Idea] Timeout & Retry #33

Description

@albertalef

Problem: Commands can hang forever; flaky commands need manual retry logic.

Solution: Add _timeout and _retry options.

# Timeout after 5 seconds
sh do
  curl("https://slow-api.example.com", _timeout: 5)
end
# Raises RubyShell::TimeoutError

# Retry on failure
sh do
  curl("https://flaky-api.example.com",
       _retry: 3,                    # Max 3 attempts
       _retry_delay: 1,              # Wait 1 second between retries
       _retry_backoff: :exponential) # 1s, 2s, 4s delays
end

# Combine timeout and retry
sh do
  curl("https://api.example.com",
       _timeout: 10,
       _retry: 3,
       _retry_on: [RubyShell::TimeoutError, RubyShell::CommandError])
end

Implementation:

  • Add Timeout.timeout wrapper in TerminalExecutor.capture
  • Create retry loop with configurable delay/backoff
  • New RubyShell::TimeoutError exception class

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions