Skip to content

fix: add timeout to subprocess calls in context_references (salvage #3380) - #3469

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-a2b72b01
Mar 28, 2026
Merged

fix: add timeout to subprocess calls in context_references (salvage #3380)#3469
teknium1 merged 1 commit into
mainfrom
hermes/hermes-a2b72b01

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #3380 by @memosr. Cherry-picked clean, no modifications needed.

_expand_git_reference() and _rg_files() call subprocess.run() without a timeout. On large repos, @diff, @staged, @git:N, or @folder: references could hang the agent indefinitely.

  • timeout=30 for git subprocess, returns user-friendly error on TimeoutExpired
  • timeout=10 for rg subprocess, returns None to trigger os.walk fallback

Closes #3380.

_expand_git_reference() and _rg_files() called subprocess.run()
without a timeout. On a large repository, @diff, @StaGeD, or
@git:N references could hang the agent indefinitely while git
or ripgrep processes slow output.

- Add timeout=30 to git subprocess in _expand_git_reference()
  with a user-friendly error message on TimeoutExpired
- Add timeout=10 to rg subprocess in _rg_files() returning
  None on timeout (falls back to os.walk folder listing)
@teknium1
teknium1 merged commit 83043e9 into main Mar 28, 2026
2 checks passed
dlkakbs added a commit to dlkakbs/hermes-agent that referenced this pull request Mar 29, 2026
All subprocess.run() calls in hermes_cli/gateway.py lacked a timeout
parameter. If systemctl, launchctl, loginctl, wmic, or ps blocks
(e.g. D-Bus unavailable, WMI service stuck, launchd unresponsive),
hermes gateway start/stop/restart/status/install/uninstall hangs
indefinitely with no feedback to the user.

Timeout values applied:
- Lifecycle commands (start/stop/restart/enable/disable/daemon-reload,
  launchctl load/unload): timeout=30
- Status/query commands (is-active, loginctl show-user, launchctl list,
  systemctl status, journalctl, tail, ps aux, wmic): timeout=5-10
- loginctl enable-linger: timeout=10

For _is_service_running() and launchd_status(), TimeoutExpired is caught
explicitly and treated as not-running, matching how non-zero return codes
are already handled. All other call sites are either inside existing
try/except Exception blocks (find_gateway_pids, _enable_systemd_linger,
get_systemd_linger_status) or raise TimeoutExpired as a clear error
instead of hanging forever.

Same class of fix as NousResearch#3469 (context_references) and NousResearch#3693 (doctor/status).
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…rch#3469)

_expand_git_reference() and _rg_files() called subprocess.run()
without a timeout. On a large repository, @diff, @StaGeD, or
@git:N references could hang the agent indefinitely while git
or ripgrep processes slow output.

- Add timeout=30 to git subprocess in _expand_git_reference()
  with a user-friendly error message on TimeoutExpired
- Add timeout=10 to rg subprocess in _rg_files() returning
  None on timeout (falls back to os.walk folder listing)

Co-authored-by: memosr.eth <96793918+memosr@users.noreply.github.com>
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…rch#3469)

_expand_git_reference() and _rg_files() called subprocess.run()
without a timeout. On a large repository, @diff, @StaGeD, or
@git:N references could hang the agent indefinitely while git
or ripgrep processes slow output.

- Add timeout=30 to git subprocess in _expand_git_reference()
  with a user-friendly error message on TimeoutExpired
- Add timeout=10 to rg subprocess in _rg_files() returning
  None on timeout (falls back to os.walk folder listing)

Co-authored-by: memosr.eth <96793918+memosr@users.noreply.github.com>
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…rch#3469)

_expand_git_reference() and _rg_files() called subprocess.run()
without a timeout. On a large repository, @diff, @StaGeD, or
@git:N references could hang the agent indefinitely while git
or ripgrep processes slow output.

- Add timeout=30 to git subprocess in _expand_git_reference()
  with a user-friendly error message on TimeoutExpired
- Add timeout=10 to rg subprocess in _rg_files() returning
  None on timeout (falls back to os.walk folder listing)

Co-authored-by: memosr.eth <96793918+memosr@users.noreply.github.com>
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…rch#3469)

_expand_git_reference() and _rg_files() called subprocess.run()
without a timeout. On a large repository, @diff, @StaGeD, or
@git:N references could hang the agent indefinitely while git
or ripgrep processes slow output.

- Add timeout=30 to git subprocess in _expand_git_reference()
  with a user-friendly error message on TimeoutExpired
- Add timeout=10 to rg subprocess in _rg_files() returning
  None on timeout (falls back to os.walk folder listing)

Co-authored-by: memosr.eth <96793918+memosr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants