Closed jajetloh closed 2 months ago
Thank you for the report! This was surprising to me too, but upon inspection I see that this was actually intended behavior :-) Now I admit that your example makes me question the rationale for this decision...
What happens here is that source_stream
is consumed by for_each
, so there is no more stream to send the value to (note that the panic actually occurs when sending on the last line, not when iterating). If for instance the stream is made mutable and for_each
is substituted by by_ref().for_each()
, then no panic is thrown.
But I agree, this behavior is too surprising and there may be legitimate reasons for dropping the stream while the simulation is still running. I am busy with urgent matters this week but I definitely want to revisit this topic, so let's keep this issue open and please don't hesitate to bump this thread in another 7 days if nothing happens.
In fact I see that this behavior is "fixed" on the main
branch because EventBuffer
, which replace EventStream
in the development version, simply ignores attempts to send to a dead endpoint without panicking.
What's more, EventSlot
does the same in both v0.2.2 and in the development version, so having EventStream
panic in this situation is at the very least inconsistent.
Since this behavior no longer occurs on the main
branch I guess we could close the issue, but if you need a 0.2.3 interim release please let me know.
Fantastic to hear it's fixed in 0.2.3, thanks for the super prompt response! Happy for this issue to be closed then, and happy to wait for the official 0.2.3 release.
Oh, sorry for the misunderstanding: what is in main
will end up in v0.3.0 which has been "soon to be released" for quite some time now ;-)
So what I meant is that if you need it now rather than in a couple of months I can make a minor v0.2.3 release with just this fix.
Ahh in that case, the 0.2.3 release sooner with the fix would be fantastic, as long as it's not too much work on your end!
Fixed in 0.2.3 :tada:
I get the following error log
Using the following minimal example
In the second-last line, I attempt to iterate over the stream. Expected behaviour would be nothing as I imagine the iterator would be empty, but instead the code panics. Or at least some explanation in the error handling of the cause. However if the second-last and last lines are swapped (so the event is sent first then we iterate over the stream), no panic is thrown, and everything works as expected.
Any chance to get this edge case looked at? Not urgent for my own use case, but I imagine other users will run into this (if they haven't already)