Skip to content

Conversation

@melle
Copy link

@melle melle commented Sep 6, 2022

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.

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.
@luizmb
Copy link

luizmb commented Sep 6, 2022

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?

@melle
Copy link
Author

melle commented Sep 7, 2022

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.

@freak4pc
Copy link
Member

I'm going to close this since it's super-old and I'm trying to clean up this repo. If this is still an issue / or something you'd like to pursue, feel free to comment and we can re-discuss. Thanks!

@freak4pc freak4pc closed this Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants