Skip to content

refactor(dash-spv): drop unreachable WouldBlock/TimedOut#753

Merged
xdustinface merged 1 commit into
v0.42-devfrom
refactor/drop-unreachable-async-read-arms
May 14, 2026
Merged

refactor(dash-spv): drop unreachable WouldBlock/TimedOut#753
xdustinface merged 1 commit into
v0.42-devfrom
refactor/drop-unreachable-async-read-arms

Conversation

@xdustinface
Copy link
Copy Markdown
Collaborator

@xdustinface xdustinface commented May 10, 2026

Tokio's AsyncReadExt::read consumes WouldBlock inside the runtime, so the future never resolves with that error kind. Read timeouts are imposed via tokio::time::timeout(..) and surface as Elapsed, not io::Error::TimedOut. The four match blocks in Peer::receive_message's framing loop kept arms for both kinds, all of which were dead code.

Drop the eight unreachable arms. The remaining Ok(0), Ok(_), ConnectionAborted/ConnectionReset, and catch-all Err(e) arms continue to surface real errors, with the catch-all converting any unanticipated io::Error into NetworkError::ConnectionFailed rather than silently masking it.

Summary by CodeRabbit

  • Bug Fixes
    • Improved network error handling to properly distinguish temporary communication timeouts from actual connection failures, enhancing system reliability, error reporting accuracy, and diagnostic capabilities for peer-to-peer network operations.

Review Change Stack

Tokio's `AsyncReadExt::read` consumes `WouldBlock` inside the runtime, so the future never resolves with that error kind. Read timeouts are imposed via `tokio::time::timeout(..)` and surface as `Elapsed`, not `io::Error::TimedOut`. The four `match` blocks in `Peer::receive_message`'s framing loop kept arms for both kinds, all of which were dead code.

Drop the eight unreachable arms. The remaining `Ok(0)`, `Ok(_)`, `ConnectionAborted`/`ConnectionReset`, and catch-all `Err(e)` arms continue to surface real errors, with the catch-all converting any unanticipated `io::Error` into `NetworkError::ConnectionFailed` rather than silently masking it.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cf47fa5e-1052-4ff9-8062-4acccdd6b94f

📥 Commits

Reviewing files that changed from the base of the PR and between dca03ce and bb02633.

📒 Files selected for processing (1)
  • dash-spv/src/network/peer.rs
💤 Files with no reviewable changes (1)
  • dash-spv/src/network/peer.rs

📝 Walkthrough

Walkthrough

The PR removes special-case error handling in the Peer::receive_message method. Four read operations no longer treat timeout-like I/O errors (WouldBlock, TimedOut) as benign "no data available" conditions; instead, those errors now propagate through existing error branches, resulting in ConnectionFailed rather than Ok(None).

Changes

Peer Message Read Error Handling

Layer / File(s) Summary
Remove WouldBlock/TimedOut Exception Handling
dash-spv/src/network/peer.rs
Four dedicated error match arms handling ErrorKind::WouldBlock and ErrorKind::TimedOut in separate read contexts (framing header loop, resync search, header buffer fill, frame buffer fill) are removed, allowing those transient timeout conditions to propagate as ConnectionFailed instead of returning Ok(None).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops through error streams so bright,
Timeouts no longer hide in gentle night—
Let WouldBlock fall through, let TimedOut show,
Connection truth will reap what we now sow! 🌙

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically summarizes the main change: removing unreachable error handling code for WouldBlock and TimedOut conditions from the async message reading logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/drop-unreachable-async-read-arms

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.23%. Comparing base (dca03ce) to head (bb02633).

Additional details and impacted files
@@            Coverage Diff             @@
##           v0.42-dev     #753   +/-   ##
==========================================
  Coverage      72.22%   72.23%           
==========================================
  Files            320      320           
  Lines          69631    69615   -16     
==========================================
- Hits           50294    50287    -7     
+ Misses         19337    19328    -9     
Flag Coverage Δ
core 76.30% <ø> (ø)
ffi 45.28% <ø> (ø)
rpc 20.00% <ø> (ø)
spv 89.86% <ø> (+0.04%) ⬆️
wallet 71.22% <ø> (ø)
Files with missing lines Coverage Δ
dash-spv/src/network/peer.rs 61.63% <ø> (+1.55%) ⬆️

... and 5 files with indirect coverage changes

@github-actions github-actions Bot added the ready-for-review CodeRabbit has approved this PR label May 10, 2026
@xdustinface xdustinface requested a review from ZocoLini May 12, 2026 05:08
@xdustinface xdustinface merged commit 3281616 into v0.42-dev May 14, 2026
40 checks passed
@xdustinface xdustinface deleted the refactor/drop-unreachable-async-read-arms branch May 14, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review CodeRabbit has approved this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants