Here's a straightforward way to create a leak in Combine:
self.cancellable = Publishers.Concatenate(
prefix: Empty<Int, Never>(completeImmediately: true),
suffix: Publishers.MergeMany(Empty(completeImmediately: true))
)
.sink { _ in }
Just concatenate a publisher with a suffix that is a MergeMany
. Interestingly if you swap the prefix
and suffix
the leak disappears, but then of course the publisher has substantially changed.
I filed a feedback about this (FB7746024), but posting here too to make sure there isn't something simple I'm missing.