Open melle opened 2 years ago
Moving discussion from Twitter. Why Sink.deinit is not calling cancelUpstream automatically (https://github.com/CombineCommunity/CombineExt/blob/main/Sources/Common/Sink.swift#L113)?
Maybe it has a reference cycle and deinit is actually not called?
I looked into it: Sink's deinit is not called. That explains why the subscriptions are not cancelled. However, I could not find any explanation for the reference being kept alive. I added the cancel to the decision code as well including another test.
The explicit cancel fixes our problem, but shadows the underlying reference cycle problem. Both tests should pass, when the cancel() calls are removed and the reference cycle has been fixed.
We noticed that cancelling an Amb publisher does not cancel any of the inner publishers. It looks like nil-ing firstSink / secondSink should do the job, but it does not work. Adding explicit cancel fixes the issue, but I’m not sure if this is the right solution.