GeezerVison is showing github.com — Add opt-in WASIX TCP and UDP socket support by youknowdot · Pull Request #9809 · RustPython/RustPython
Conversation
youknowdot
commented
Nov 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Add real TCP/UDP socket operations for wasm32-wasip1 through an opt-in wasix feature, tested with Wasmer 7.5.0.
- Connect socket construction, bind/listen/accept/connect, send/receive, forward DNS and endpoint names to the WASIX host ABI.
- Support blocking, nonblocking and timeout operations with polling, byte-buffer I/O,
makefile, sendfile, duplication and descriptor ownership.
- Fix the WebAssembly constructor's positional/keyword arguments. Remove fabricated fd 0, successful no-op socket options and invented addresses.
- Keep portable preview1 builds free of WASIX imports. Unsupported hosts reject socket construction with
ENOTSUP.
- Add loopback and denied-capability tests to the WASI CI job. Native Unix/Windows socket implementation and hot paths are unchanged.
Validation
- Wasmer guest integration at
703423b4d2: 22 tests passed, including IPv4/IPv6 TCP, UDP, DNS, timeouts, partial reads, file-like I/O, an actual HTTPServer request/response, and descriptor lifetime/error cases.
- Networking disabled: real
ENOTSUP, no fabricated success.
- Portable preview1 without the feature: explicit unsupported socket construction passed.
- Host ABI layout/unit tests: 3 passed under Wasmer; additional probes covered explicit protocols, socket options and raw descriptor ownership.
- WASI Clippy at
703423b4d2, with and without wasix: passed with no warnings in changed code; existing unrelated WASI warnings remain.
- Pre-commit hooks and actionlint passed. Zizmor has no new findings; the same four low-severity findings exist on main, and the medium-or-higher scan passes.
- Native workspace tests and doctests: 1,542 passed, 20 ignored, 0 failed.
- Separate C API tests: 149 passed, 2 ignored, 0 failed.
- Native workspace and separate C API strict Clippy (
--all-targets -- -D warnings): passed.
- Native release at
564694cf31: 58 selected socket regressions ran: 56 passed and 2 existing skips, covering TCP/UDP, socket pairs, nonblocking I/O, file objects, timeouts, buffers and server helpers.
- Native loopback timing sanity check: 2,000 bidirectional 32-byte round trips, 7 samples, median 10.13 ms. No exact-main optimized binary was available, so this is not a controlled performance-regression comparison.
The unchanged stdlib_socket snippet under WASIX stops at its assumption that one recv() returns an entire sent file. WASIX can return a valid short read. The new integration test checks the complete 32 KiB transfer with a receive loop; no existing assertion or skip was changed.
Native full-suite limits were also recorded rather than hidden:
-m test test_socket aborts in dns-lookup 4.0.2 while decoding a localized error (test_getaddrinfo_localized_error, UTF-8 unwrap, exit 101).
- The native
stdlib_socket snippet reaches its NETLINK case and fails with host EPERM.
- Both outcomes reproduce with the previously built
38d813fba3 interpreter using this branch's same Lib. Native socket implementation files are unchanged by this PR. The final 703423b4d2 follow-up changes only the WASM socket module, WASIX integration test and documentation; native gates above ran at 564694cf31.
Host requirements and limits
WASIX extensions are not standard WASI preview1. The feature needs a host providing wasix_32v1 and networking permission, such as Wasmer's --net. It is opt-in so ordinary preview1 artifacts remain portable.
This does not add Unix/raw sockets, ancillary messages, multicast configuration, reverse DNS, system hostname/service lookup, IPv6 scope IDs or TLS. Unsupported flags/options fail explicitly. Wasmer cannot identify the type of rewrapped TCP listeners or bound UDP sockets; these require explicit constructor metadata, and SO_TYPE reports ENOTSUP if the host cannot establish the actual type.
Build/run instructions and capability details: wasm/WASIX.md.
AI assistance: OpenAI Codex implemented the backend, tests and documentation and ran the listed validation. The runtime did not expose its model version.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Replace the WebAssembly socket placeholder with a real Wasmer WASIX backend behind an explicit wasix feature. Connect TCP, UDP, forward DNS, polling, timeout handling and descriptor ownership to Python socket APIs, and reject unavailable capabilities rather than fabricating successful operations.
Add loopback and capability-denial integration tests while preserving the portable preview1 build and native socket paths.
AI assistance: OpenAI Codex implemented the backend, integration tests and documentation and ran the recorded validation. The model version was not exposed by the runtime.
Assisted-by: Codex:unreported
Use the VM unlocked buffer helper for send, sendall and sendto so blocking host calls and signal callbacks never retain an exporter payload lock. Cover bytearray and memoryview sends in the WASIX integration suite.
AI assistance: OpenAI Codex reviewed buffer lifetimes, applied the fix and ran validation.
Assisted-by: Codex:unreported
Check the shared deadline before every I/O attempt, including retries that continue making progress, and exercise sendall with a full peer receive window.
AI assistance: OpenAI Codex reviewed deadline handling and added the fix and regression coverage.
Assisted-by: Codex:unreported
Queue a byte before starting the timed send so the subsequent receive does not assume that a timed-out operation sent a prefix.
AI assistance: OpenAI Codex reviewed and adjusted the new test.
Assisted-by: Codex:unreported
coderabbitai
Bot
commented
Nov 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Important
Draft PR not reviewed
Draft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration:
reviews:
auto_review:
drafts: true
Pre-merge checks: 1 · 1
-
Failed checks: 1 inconclusive
| Check name |
Status |
Explanation |
Resolution |
| Title check |
 |
This assessment has not completed. The check will be retried on the next pre-merge check run. |
|
Passed checks: 1 passed
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Expose unsupported reverse lookup as an OS error so socket.getfqdn can use its documented explicit-name fallback. Exercise a real HTTPServer request through WASI select and document the wildcard-hostname limit.
AI assistance: implemented and validated with OpenAI Codex; the runtime did not expose the model version.
Assisted-by: Codex:unreported
Merging this PR will not alter performance
✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1
Comparing youknowdot:feat/wasi-sockets-20261112 (703423b) with main (5713e58)2
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Use CPython's flags-based signature fallback for module-level close and dup, matching the native socket backend. Keep descriptor conversion and networking behavior unchanged. The existing builtin_signature snippet covers both functions.
AI assistance: implemented and validated with OpenAI Codex; the runtime did not expose the model version.
Assisted-by: Codex:unreported
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|