rust-lang / futures-rs

Zero-cost asynchronous programming in Rust
https://rust-lang.github.io/futures-rs/
Apache License 2.0
5.34k stars 616 forks source link

Unreachable match arm in FillBuf is reachable #2727

Closed jessa0 closed 9 months ago

jessa0 commented 1 year ago

I hit this unreachable!() inside FillBuf with an AsyncRead implementation (wrapped in a BufReader) which calls a Javascript callback thru neon (which is an async operation) for the actual read, which means every "new" poll_read (i.e. either the first call ever or the first call after a Ready is returned) will return Pending at least once, including after EOF is hit, which is what triggers this bug. Of course, the AsyncRead implementation could track when EOF is hit and return Ready(0) forever after that, which is indeed what I used as a workaround, but I can't find anything in the AsyncRead documentation which actually requires implementors to do this.

See #2722 for a possible bug fix.

jessa0 commented 9 months ago

Fixed by #2801