7842: Use select! instead of joins in connect_(tcp|udp) examples#48
7842: Use select! instead of joins in connect_(tcp|udp) examples#48martin-augment wants to merge 2 commits intomasterfrom
Conversation
Pull Request ReviewCritical Issue: Incorrect Semantic ChangeThis PR introduces a critical bug by replacing
Impact on
|
🤖 Augment PR SummarySummary: Switches the TCP/UDP connect examples from 🤖 Was this summary useful? React with 👍 or 👎 |
| match future::join(sink.send_all(&mut stdin), stdout.send_all(&mut stream)).await { | ||
| (Err(e), _) | (_, Err(e)) => Err(e.into()), | ||
| _ => Ok(()), | ||
| tokio::select! { |
There was a problem hiding this comment.
tokio::select! will end connect() as soon as either direction finishes, which means an stdin EOF will now stop draining any remaining socket output (and the non-selected branch’s error/result is dropped). If the example is intended to behave like a full duplex “pipe” until the peer closes, it might be worth double-checking this termination semantics (also applies to the UDP change).
🤖 Was this useful? React with 👍 or 👎
There was a problem hiding this comment.
value:incorrect-but-reasonable; category:bug; feedback:The Augment AI reviewer is not correct! The connect-tcp/udp examples are just demos of how to connect to a server and send/receive data to/from it. The proposed changes suggest to exit the client application (e.g. connect-tcp) if either of its stdin or stdout handles are closed. After closing the stdin of the connect-tcp app it won't be able to send any more data and it won't be usable.
| _ => Ok(()), | ||
| tokio::select! { | ||
| r = sink.send_all(&mut stdin) => r?, | ||
| r = stdout.send_all(&mut stream) => r?, |
There was a problem hiding this comment.
Using select! causes premature termination and data loss
Medium Severity
Replacing join/try_join! with select! fundamentally changes the semantics. The original code waited for both stdin→socket and socket→stdout operations to complete. The new code exits as soon as either completes, cancelling the other. When stdin reaches EOF, the program now exits immediately without waiting for pending server responses, potentially losing data. The examples are documented to "print all data received on stdout," which this change breaks.
Additional Locations (1)
There was a problem hiding this comment.
value:incorrect-but-reasonable; category:bug; feedback:The Bugbot AI reviewer is not correct! The connect-tcp/udp examples are just demos of how to connect to a server and send/receive data to/from it. The proposed changes suggest to exit the client application (e.g. connect-tcp) if either of its stdin or stdout handles are closed. After closing the stdin of the connect-tcp app it won't be able to send any more data and it won't be usable.
value:incorrect-but-reasonable; category:bug; feedback:The Claude AI reviewer is not correct! The |
7842: To review by AI