Skip to content

sockets: Add error code for EPIPE (and ECONNABORTED on Windows)#887

Open
badeend wants to merge 1 commit intoWebAssembly:mainfrom
badeend:connection-broken
Open

sockets: Add error code for EPIPE (and ECONNABORTED on Windows)#887
badeend wants to merge 1 commit intoWebAssembly:mainfrom
badeend:connection-broken

Conversation

@badeend
Copy link
Member

@badeend badeend commented Feb 25, 2026

WASI sockets currently has no error code corresponding to EPIPE. When writing to a closed/broken socket:

  • POSIX systems return EPIPE
  • Windows returns ECONNABORTED

After searching around, this Windows-specific discrepancy is well-known:


WASI doesn't have a good solution for it now:

  • By the time the OS reports EPIPE, previously acknowledged writes may have been lost and and the guest should be informed about that. So swallowing the error is not right.
  • Mapping it to ECONNRESET isn't right either, beause that implies that the peer actively reset the connection.
  • Mapping (or: leaving) it as ECONNABORTED isn't optimal either, because that error code is usually only returned by accept and sometimes connect on Unix-like systems.

I think this warrants a new error code. I've called it connection-broken. I expect wasi-libc to map this to EPIPE.


Wasmtime currently maps EPIPE to ok(()). With the new error code in place, this test can be updated to consistently expect an error cross platform.

@badeend badeend requested a review from a team as a code owner February 25, 2026 15:59
@github-actions github-actions bot added the P-sockets Proposal: wasi-sockets label Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P-sockets Proposal: wasi-sockets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant