Repository navigation
fix(node): keep the error chain when handlers return AcceptError - #2251
Conversation
The client, DHT and probe ProtocolHandler::accept impls wrapped the anyhow error as AcceptError::from_err(io::Error::other(e.to_string())). to_string() keeps only the top-level message, so every source() cause was dropped before iroh saw the error. AcceptError::from_boxed takes the anyhow error as a boxed dyn Error. AcceptError::User is #[error(transparent)], so Display is unchanged and the full cause chain stays reachable through source(). The probe signing comment now states why that path logs at error level itself. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The change is a small, consistent, correctness-preserving refactor applied uniformly to all three handlers with no remaining occurrences of the old pattern and an accurate comment update.
Review effort: Balanced
Findings: None
What changed in this PR
This PR fixes error-context loss in the three ProtocolHandler::accept implementations of the decdn-node daemon. Previously each handler flattened its anyhow::Error into AcceptError::from_err(std::io::Error::other(e.to_string())), which kept only the top-level message and discarded the entire source() cause chain. The handlers now use AcceptError::from_boxed(e.into()); since AcceptError::User is #[error(transparent)], the Display output is unchanged while the full cause chain remains reachable via source().
I verified that serve() returns anyhow::Result<()> in each handler, that all three call sites were updated with no leftover instances of the old pattern, and that the anyhow::Error → Box<dyn Error + Send + Sync> conversion preserves the chain. The probe comment update accurately explains why that path logs at error level itself (iroh logs a failed handler only at warn level with the top-level message).
Changes:
- Replace lossy
AcceptError::from_err(io::Error::other(e.to_string()))withAcceptError::from_boxed(e.into())in the client, DHT, and probe handlers to retain the full error cause chain. - Update the probe slash-signing comment to state the real reason it logs at error level.
| File | Description |
|---|---|
| crates/node/src/handlers/probe.rs | Preserves error chain in accept; clarifies the slash-signing error-log rationale comment. |
| crates/node/src/handlers/dht.rs | Preserves error chain in accept via from_boxed. |
| crates/node/src/handlers/client/mod.rs | Preserves error chain in accept via from_boxed. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit 03f3c41 in the Show a line coverage summary of the most impacted files.
|
Summary
ProtocolHandler::acceptimpls converted theiranyhow::ErrorwithAcceptError::from_err(std::io::Error::other(e.to_string())), which keeps only the top-level message and drops everysource()cause.AcceptError::from_boxed(e.into()).AcceptError::Useris#[error(transparent)], so Display is unchanged and the full cause chain stays reachable throughsource().Test plan
cargo fmt -- --check: cleancargo clippy --workspace --all-targets --all-features: no issuescargo nextest run -p decdn-node --no-fail-fast: 1513/1513 passed (1 flaky retry innode_origin_pull)node_origin_pull a_probe_cache_hit_*tests are flaky here and fail the same way on unmodified origin/main (reproduced with 5 runs each), so the flake predates this change🤖 Generated with Claude Code