Skip to content

Catch WouldBlock alongside TimedOut in Serial::Port's read_byte - #61

Merged
harshverma27 merged 1 commit into
mainfrom
claude/issue-51-fix
Jun 30, 2026
Merged

Catch WouldBlock alongside TimedOut in Serial::Port's read_byte#61
harshverma27 merged 1 commit into
mainfrom
claude/issue-51-fix

Conversation

@harshverma27

Copy link
Copy Markdown
Owner

Fixes #51

Summary

  • Serial::read_byte's Port variant only mapped ErrorKind::TimedOut to Ok(None), unlike the Tcp variant which also catches ErrorKind::WouldBlock. Some serialport backends report a timed-out read as WouldBlock rather than TimedOut, which used to surface as Err here, breaking the documented "Ok(None) means nothing arrived in time, not an error" contract.
  • Added WouldBlock to the Port branch's match guard, matching the Tcp branch.

Test plan

  • Added a WouldBlockPort test stub implementing serialport::SerialPort whose read always returns ErrorKind::WouldBlock, and a regression test asserting read_byte returns Ok(None) for it.
  • cargo test -p nucleus-test-sdk --lib — 9 passed.
  • cargo clippy -p nucleus-test-sdk --all-targets -- -D warnings — clean.
  • cargo fmt --all -- --check — clean.

Generated by Claude Code

The Port branch of read_byte only mapped ErrorKind::TimedOut to
Ok(None), unlike the Tcp branch which also catches WouldBlock. Some
serialport backends report a timed-out read as WouldBlock, which used
to surface as an Err here instead of honoring the documented Ok(None)
timeout contract.
@harshverma27
harshverma27 merged commit 785bce5 into main Jun 30, 2026
5 checks passed
@harshverma27
harshverma27 deleted the claude/issue-51-fix branch June 30, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

serial read_byte: WouldBlock not caught in Port branch, breaking Ok(None) timeout contract

2 participants