Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amb: forward cancel to the inner publishers #144

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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.

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.

2 participants