Skip to content

fix(wasix): preserve nonblocking connect errors - #6858

Open
kilyanni wants to merge 3 commits into
mainfrom
sock-connect-errno
Open

fix(wasix): preserve nonblocking connect errors#6858
kilyanni wants to merge 3 commits into
mainfrom
sock-connect-errno

Conversation

@kilyanni

@kilyanni kilyanni commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Preserve the underlying error when a nonblocking socket connection fails.

@kilyanni
kilyanni requested review from Arshia001 and a lite review from Copilot August 5, 2026 17:06
@kilyanni
kilyanni marked this pull request as ready for review August 5, 2026 17:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃煛 Changes recommended

It introduces new variants to the public virtual-net::NetworkError enum (a breaking API surface change) without corresponding versioning/release-note handling.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR improves nonblocking socket connect error reporting in WASIX by preserving and surfacing the underlying connect failure (e.g., ECONNREFUSED, ENETUNREACH, EHOSTUNREACH) instead of collapsing failures to ENOTCONN.

Changes:

  • Extend virtual networking errors with NetworkUnreachable and HostUnreachable, including IO error kind and OS error code mappings.
  • Map the new virtual-net errors to WASIX Errno values (Netunreach, Hostunreach).
  • Update sock_connect鈥檚 nonblocking path to read and return the socket鈥檚 latched last error on Closed/Failed, falling back to ENOTCONN when none is recorded.
File summaries
File Description
lib/wasix/src/syscalls/wasix/sock_connect.rs Uses the socket鈥檚 latched last_error() to return the real connect failure for nonblocking connects.
lib/wasix/src/net/mod.rs Maps new NetworkError variants to WASIX Errno values.
lib/virtual-net/src/lib.rs Introduces NetworkUnreachable/HostUnreachable and maps them to/from std::io::ErrorKind and relevant libc codes.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

We're testing this review assessment. Please use 馃憤 or 馃憥 to tell us if it's correct.

Comment on lines 888 to +896
/// The operation is not supported.
#[error("unsupported")]
Unsupported,
/// The network containing the remote host is not reachable.
#[error("network unreachable")]
NetworkUnreachable,
/// The remote host is not reachable.
#[error("host unreachable")]
HostUnreachable,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... oh. Right. Well that's fun ^^'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

virtual-net is not stable yet and breaking changes aren't unexpected. Indeed, with each release, we bump the minor.

@kilyanni
kilyanni removed the request for review from Arshia001 August 5, 2026 17:50
@kilyanni
kilyanni force-pushed the sock-connect-errno branch from 2b2eae0 to 7a293fd Compare August 5, 2026 17:51
@kilyanni
kilyanni requested a review from Arshia001 August 5, 2026 17:55
@kilyanni
kilyanni requested a review from syrusakbary as a code owner August 6, 2026 13:23
Comment thread lib/cli/Cargo.toml Outdated
@kilyanni
kilyanni force-pushed the sock-connect-errno branch from fa6e437 to dad7861 Compare August 6, 2026 13:53

@Arshia001 Arshia001 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to go as soon as we add tests for it in wasm_tests.

@kilyanni
kilyanni requested a review from Arshia001 August 7, 2026 13:42
@kilyanni
kilyanni force-pushed the sock-connect-errno branch from cb8180e to 8c2caa8 Compare August 7, 2026 15:04
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.

4 participants