Fix WASIX socket connect to detect connection failures#6059
Draft
Fix WASIX socket connect to detect connection failures#6059
Conversation
Handle POLLERR in poll_write_ready to detect failed TCP connections. When POLLERR is detected, use getsockopt with SO_ERROR to retrieve the actual socket error and propagate it properly. This fixes the issue where socket connections always appeared successful even when they failed (e.g., connection refused). Co-authored-by: zebreus <1557253+zebreus@users.noreply.github.com>
- Use explicit cast to libc::c_void for better clarity - Properly handle getsockopt failure case with last_os_error - Handle edge case where POLLERR is set but SO_ERROR is 0 - Improve error handling robustness with better fallback logic Co-authored-by: zebreus <1557253+zebreus@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix WASIX socket connect to return correct failure status
Fix WASIX socket connect to detect connection failures
Jan 15, 2026
Contributor
|
@copilot check again |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Socket connect operations in WASIX always returned success, even when connections failed (e.g., ECONNREFUSED). This broke applications that probe ports for availability.
Root Cause
poll_write_readyinLocalTcpStreamonly checkedPOLLOUTandPOLLHUPflags. When TCP connections fail, the OS setsPOLLERR, which was being ignored.Changes
POLLERRto poll flags inpoll_write_ready(lib/virtual-net/src/host.rs)POLLERRis detected, retrieve actual error viagetsockopt(SO_ERROR)and propagate asNetworkErrorgetsockoptfailure,POLLERRwithSO_ERROR=0Before:
After:
This follows standard POSIX socket error handling and enables port probing logic.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
registry.wasmer.io/home/REDACTED/work/wasmer/wasmer/target/debug/deps/wasmer_wasix-539a270b3a08905e /home/REDACTED/work/wasmer/wasmer/target/debug/deps/wasmer_wasix-539a270b3a08905e 5-cgu.0.rcgu.o stup/toolchains//home/REDACTED/work/wasmer/wasmer/target/debug/build/blake3-de6d20debuginfo=2 n/rustc -f39�� o ld/syn-f84641bab/home/REDACTED/work/wasmer/wasmer/target/debug/deps/wasmer_derive-feature="std" f/num_enum-0.7.5/src/lib.rs c6597.tracing_test_macro.db42951b32e2e2f8-cgu.0.rcgu.o c6597.tracing_test_macro.db42951b32e2e2f8-cgu.1.rcgu.o own-linux-gnu/li--64 c6597.28uagvhqakf0ge67mb1wav86y.rcgu.o own-�� a8ae0c185c/out/1/tmp/ccDYIUaT.s 6b65.rlib(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.