Skip to content

[PR #31] WebSocket connect has no timeout — unreachable RPC hangs process forever #89

@obchain

Description

@obchain

PR: #31 (feat/06-chainprovider-ws)
File: crates/charon-scanner/src/provider.rs
Line: 36

Problem: ProviderBuilder::new().on_ws(ws).await has no deadline. If BSC node unreachable, TCP handshake or WS upgrade stalls indefinitely, blocking async runtime task and preventing process from starting or recovering.

Impact: Docker container on Hetzner CX22 (PR #55 compose stack) appears hung with no log output. Ops cannot distinguish slow node from crashed one. No restart logic fires because task never yields error.

Fix: Wrap with tokio::time::timeout:

use tokio::time::{timeout, Duration};

let provider = timeout(
    Duration::from_secs(10),
    ProviderBuilder::new().on_ws(ws),
)
.await
.with_context(|| format!("chain '{name}': ws connect timed out after 10s"))?
.with_context(|| format!("chain '{name}': ws connect failed"))?;

Expose timeout as configurable field in ChainConfig (default 10s).

Metadata

Metadata

Assignees

No one assigned

    Labels

    layer:rustRust crates (core / scanner / protocols / executor / cli)pr-reviewFindings from PR review processpriority:p1-coreCore MVP scope

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions