Skip to content

[BUG] TCP Client Has No Read/Write Timeout #98

@olddev94

Description

@olddev94

Project

vgrep

Description

The HTTP client in src/server/client.rs uses TcpStream::connect() without setting read or write timeouts. If the server hangs or the network is slow, the client will block indefinitely with no way to cancel except killing the process.

Error Message

No error - client hangs indefinitely (no timeout).

Debug Logs

System Information

- Bounty Version: 0.1.0
- OS: Ubuntu 24.04 LTS
- Rust: 1.75+

Screenshots

No response

Steps to Reproduce

  1. Start a server that accepts connections but doesn't respond:
    nc -l 7777 &  # Accept connection but never respond
  2. Run vgrep in server mode pointing to that port:
    vgrep config set mode server
    vgrep search "test"
  3. Observe the client hangs forever waiting for response
  4. Must Ctrl+C to cancel - no automatic timeout

Expected Behavior

The client should:

  1. Set a reasonable connect timeout (e.g., 5 seconds)
  2. Set read/write timeouts (e.g., 30-60 seconds for embedding operations)
  3. Return a clear timeout error if server doesn't respond

Actual Behavior

  1. No timeouts are set
  2. Client blocks indefinitely on:
    • TcpStream::connect() if host is unreachable
    • write_all() if network is congested
    • read_to_string() if server hangs
  3. User must Ctrl+C or kill the process

Additional Context

This affects all client operations:

  • search() - Line 70
  • embed_batch() - Line 118
  • is_server_running() - Line 161

The issue is particularly problematic when:

  • Server crashes mid-request
  • Network connectivity issues occur
  • Server is overloaded with large embedding batches
  • Running in automated scripts/CI where hanging is costly

A configurable timeout (e.g., VGREP_TIMEOUT env var) would be ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingideIssues related to IDEinvalidThis doesn't seem rightvgrep

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions