hermes - ✅(Solved) Fix [Bug]: browser_tool _get_command_timeout crashes with TypeError after cleanup race [2 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#14783Fetched 2026-04-24 06:14:43
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×3cross-referenced ×2commented ×1

Fix Action

Fixed

PR fix notes

PR #14779: fix(tools): guard _get_command_timeout against None return after browser cleanup race

Description (problem / solution / changelog)

What does this PR do?

Guards _get_command_timeout() in browser_tool.py against returning None after a browser cleanup race condition, preventing a TypeError crash.

Related Issue

Fixes #14783

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • tools/browser_tool.py: Added None guard in _get_command_timeout()
  • tests/tools/test_browser_timeout_race.py: 3 tests for the race condition

How to Test

python -m pytest -o 'addopts=' tests/tools/test_browser_timeout_race.py -v

Result: 3 passed.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs
  • My PR contains only changes related to this fix
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: macOS 15 (Darwin 24.6.0), Python 3.14.2

Documentation & Housekeeping

  • N/A for all documentation items

Changed files

  • tests/tools/test_browser_timeout_race.py (added, +47/-0)
  • tools/browser_tool.py (modified, +1/-1)

PR #14843: fix(browser): guard command timeout cache invalidation

Description (problem / solution / changelog)

Summary

  • make tools.browser_tool._get_command_timeout() fall back to the default timeout when cleanup invalidates the cached value mid-read
  • preserve the existing cache behavior for valid integer timeouts
  • add a regression test for the cleanup race window

Testing

  • python3 -m pytest -o addopts='' -q tests/tools/test_browser_hardening.py

Closes #14783

Changed files

  • tests/tools/test_browser_hardening.py (modified, +8/-0)
  • tools/browser_tool.py (modified, +8/-1)
RAW_BUFFERClick to expand / collapse

Describe the bug

_get_command_timeout() in tools/browser_tool.py can return None after a browser cleanup race condition, causing a TypeError crash when the return value is used in arithmetic.

Steps to reproduce

  1. Trigger a browser tool command that races with browser cleanup/shutdown
  2. _get_command_timeout() returns None instead of a numeric value
  3. TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Expected behavior

_get_command_timeout() should always return a valid numeric timeout, falling back to a default when the browser state is unavailable.

Environment

  • Hermes Agent version: current main
  • OS: any

extent analysis

TL;DR

The most likely fix is to modify _get_command_timeout() in tools/browser_tool.py to return a default numeric timeout when the browser state is unavailable.

Guidance

  • Review the implementation of _get_command_timeout() to identify the root cause of the None return value and consider adding a default return value.
  • Verify that the function handles the browser cleanup/shutdown scenario correctly to prevent the TypeError crash.
  • Consider adding error handling or input validation to ensure that the return value of _get_command_timeout() is always a valid numeric type.
  • Test the modified function with the steps to reproduce to ensure the fix resolves the issue.

Example

def _get_command_timeout():
    # existing implementation
    timeout = ...  # calculate timeout
    if timeout is None:
        return 60  # default timeout in seconds
    return timeout

Notes

The exact implementation of the default return value may vary depending on the specific requirements of the browser tool.

Recommendation

Apply workaround: Modify _get_command_timeout() to return a default numeric timeout when the browser state is unavailable, as this directly addresses the root cause of the TypeError crash.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

_get_command_timeout() should always return a valid numeric timeout, falling back to a default when the browser state is unavailable.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING