We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d009fe4 commit f28c149Copy full SHA for f28c149
1 file changed
crates/wasi/src/preview2/tcp.rs
@@ -81,9 +81,16 @@ impl HostInputStream for HostTcpSocketInner {
81
}
82
83
let mut buf = bytes::BytesMut::with_capacity(size);
84
- let n = self.stream.try_read_buf(&mut buf)?;
+ let n = match self.stream.try_read_buf(&mut buf) {
85
+ Ok(n) => n,
86
+ Err(e) if e.error_kind() == std::io::ErrorKind::WouldBlock => 0,
87
+ Err(_) => {
88
+ // FIXME: this is a closed stream, but we need to record it for future calls to
89
+ // ready
90
+ return Ok((Bytes::new(), StreamState::Closed));
91
+ }
92
+ };
93
- // TODO: how do we detect a closed stream?
94
buf.truncate(n);
95
Ok((buf.freeze(), StreamState::Open))
96
0 commit comments