A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Implement the new ConnectionBroken error code. (#12840)
Dave Bakker13a2f497115c
diff --git a/crates/test-programs/src/bin/p3_sockets_tcp_streams.rs b/crates/test-programs/src/bin/p3_sockets_tcp_streams.rsindex dc9f30c9de..e01832980b 100644--- a/crates/test-programs/src/bin/p3_sockets_tcp_streams.rs+++ b/crates/test-programs/src/bin/p3_sockets_tcp_streams.rs@@ -101,7 +101,8 @@ async fn test_tcp_send_drops_stream_when_remote_shutdown(family: IpAddressFamily}}- _ = client.send_result.await;+ let result = client.send_result.await;+ assert!(matches!(result, Err(ErrorCode::ConnectionBroken)));}).await;}diff --git a/crates/wasi/src/p3/sockets/host/types/tcp.rs b/crates/wasi/src/p3/sockets/host/types/tcp.rsindex b6b1ddcbbb..6a0871565b 100644--- a/crates/wasi/src/p3/sockets/host/types/tcp.rs+++ b/crates/wasi/src/p3/sockets/host/types/tcp.rs@@ -226,10 +226,14 @@ impl<D> StreamConsumer<D> for SendStreamConsumer {Poll::Pending => return Poll::Pending,}}- Err(err) if err.kind() == std::io::ErrorKind::BrokenPipe => {- break 'result Ok(());+ Err(err) => {+ break 'result Err(match err.kind() {+ // ECONNABORTED is the closest thing to EPIPE on Windows.+ std::io::ErrorKind::BrokenPipe+ | std::io::ErrorKind::ConnectionAborted => ErrorCode::ConnectionBroken,+ _ => err.into(),+ });}- Err(err) => break 'result Err(err.into()),}}};