Description
I wrote some async code recently that looked roughly like this:
- create MPSC channel
- spawn huge collection of tasks that do some work and transmit messages on the channel. Each task returns
Result
so that?
can bubble up errors. - process messages received
- when channel is closed, await all the tasks (with
??
on the result of each await, since its aResult<Result<..>>
).
This phenomenon occurred: I did not see as much useful work out of the tasks that I expected. Here is why: Many of the tasks went on the error path (I was hitting local resource limitations), but I didn't have any code that tried to report that the error path was being executed. So those errors would not be observed until step 4 above, when we started awaiting all the tasks and would actually get panics from the ??
At one point I was using the console to try to figure out what was going on. It did not illuminate anything for me.
But: it could have. Namely, the fact that so many of those tasks were returning error ended up being a significant hint, and is something that we could report succinctly.