HI version is available. Content is displayed in original English for accuracy.
Advertisement
Advertisement
⚡ Community Insights
Discussion Sentiment
17% Positive
Analyzed from 554 words in the discussion.
Trending Topics
#return#result#error#let#function#value#case#self#linter#rust

Discussion (9 Comments)Read Original on HackerNews
https://github.com/hyperium/hyper/issues/4022
Saved you 3000 words
The race condition aspect makes it worse: it only triggers when the reader is slower than the writer, which in production means it's intermittent and load-dependent. The kind of thing synthetic monitoring almost never catches because your test client is usually fast.
In any case, the return value is being “handled” - the question mark examines the result and breaks the loop if the result is not `Ok(…)`, ie if the call is not successful.
Intentionally ignoring the successful return value isn’t necessarily terrible, either - you could be calling the function for its side effect, and you don’t care what the specific result of that effect is, just as long as there is some effect. E.g. maybe you have a state machine, and this is the code that repeatedly drives it.
(Not coincidentally, polling is what you do to Futures, and Futures are state machines that you need to repeatedly drive…)
In conclusion, I do not think this is prima facie terrible code, nor is it an obvious bug. Async rust is subtle and complicated, and not always fully understood by those who nevertheless have to use it.
I see in the article they did change the poll_flush to run just-in-time at poll_shutdown. So they definitely can make a "best effort" poll_flush version that just does not return any errors for use in that loop.
But all in all? Amateur hour.