Closed rubensworks closed 2 years ago
Thanks for reporting; however, I don't fully understand the case yet. What is the relationship between baseIterator
and transformIt
?
Ah, apologies, there was a typo in the example. Updated now, should make more sense :-)
It's a matter of ownership indeed; the baseIterator
was created outside of the TransformIterator
, and ownership was never transfered.
Perhaps a destroyed
event is what we need then?
Perhaps a destroyed event is what we need then?
Yes, I think that would help for these cases.
Super, following up in https://github.com/RubenVerborgh/AsyncIterator/issues/95
I don't think it's really a bug, but nevertheless, I think it deserves some discussion.
Yesterday, I discover some edge-cases in which chained iterators would keep on running (due to an infinite iterator in the chain), even though the head of the chain was destroyed. While destroy calls should be propagated (unless
destroySource
is set tofalse
), this was not happening in this case.The root cause of these problems seemed to be caused by TransformIterators with an (async) callback-based reference to another iterator, where this iterator was created externally.
They shared the following form:
In cases where
transformIt
(or some other iterator in the chain fromtransformIt
) was destroyed before it was being read,baseIterator
would not be destroyed. This makes sense of course, because the callback in theTransformIterator
is never invoked, which breaks the destroy call chainbaseIterator
.I've created a workaround for these cases, so the problem is solved on my end. But I thought it would be good to raise this issue here as well. Perhaps it can help someone with debugging in the future.