-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Version
latest master
Platform
any
Description
This comes from rust-lang/miri#4367, where we hit this behavior in the Miri test suite.
let mut file = File::create(&path).await?;
file.write_all(b"some bytes").await?;
assert_eq!(file.metadata().await.unwrap().len(), 10);While of course write_all is not guaranteed to actually flush to disk, the assumption that a single thread of execution sees the results after a write seems to be true for normal sync code (and is very intuitive), but this assumption does not hold for async code using tokio.
Tokio File just does an early return after starting the thread for the write asynchronously.
Line 763 in ab8d7b8
| return Poll::Ready(Ok(n)); |
The code is written in a way that makes this look deliberate, but I could not find documentation about this rather surprising behavior, so consider this more of a documentation request, though of course making it behave consistently would be useful too (but maybe slower?).