Combine `.receive(on: RunLoop.main)` loses sent value. How can I make it work?

Matt Gallagher has been doing a rather deep dive into Combine on his blog (part 1, part 2, part 3) which may shed some more detailed light on the behaviors seen in this thread. Namely, part 3 deals with the exact same receive issues discussed here, along with many other async scenarios using Combine. He specifically recommends four things:

  1. Subscription and other “black boxes” should be fully documented (we shouldn’t be guessing about thread safety and graph lifecycles)
  2. support buffered subjects and other ways of sharing cached computations
  3. support scenarios where demand must never be zero
  4. receive(on:) should synchronously establish initial demand (only subscribe(on:) should asynchronously complete construction)

As an aside, to me, open sourcing Combine could take care of #1, or at least make it possible for the community to contribute documentation.


If failure and completion are sent asynchronously from values, then it would be easy to "lose" the last values sent before a completion. Setup (receive(subscription:)) is a bit of a different case since here since we're talking about if it's first & synchronous or first & asynchronous.

1 Like

Hello all,

As of developer beta 1 of iOS 13.3 (and associated releases for other platforms), we've changed the behavior of receive(on:) plus other Scheduler operators to synchronously send their subscription downstream. Previously, they would "async" it to the provided scheduler.

This means that the test case in the original post of this thread now does what most would expect (print the value). Since the subscription is received synchronously by sink, and it synchronously requests .unlimited from its upstream, there is no opportunity for any values sent to the PassthroughSubject to be dropped.

If you have access to the developer betas, please give it a try with your own Combine scenarios and let me know how it goes.

I'd like to extend a special thank you to everyone here and elsewhere across the web who provided us valuable feedback on this.


Hi @Tony_Parker I am facing a similar issue, stated below is the example:

Xcode 11.2.1 (11B500)


When .receive(on: RunLoop.main) is used sink doesn't receive any values, however when it is commented out, then sink receives values.

Note: I have tried the following but still doesn't work:

  • Retained cancellable
  • Tested on iOS Device / Simulator / Playground.


import Foundation
import Combine

extension Notification.Name {
    public static let didPost = Notification.Name("didPost")

func postNotifications() {
    let names = ["aaa", "bbb", "ccc"]
    for name in names {
                                        object: nil,
                                        userInfo: ["Car" : name])

let cancellable = NotificationCenter.default.publisher(for: .didPost)
    .compactMap { $0.userInfo?["Car"] as? String }
    .receive(on: RunLoop.main) //works when commented out
    .sink {
        print("sink: \($0)")


Hi @somu,

What version of iOS are you testing on?


Following are the versions:
iPhone: iOS 13.2.3 (17B111)
iOS Simulator: iOS 13.2.2

Are you able to test using the new behavior on iOS 13.3 (beta)?

1 Like

Oops my bad, I haven't tested it on iOS 13.3 (beta), will test it and post the results.

@Tony_Parker @clayellis, sorry about the confusion, I have tested using Xcode Beta 11.3 beta (11C24b) using the iOS 13.3 simulator and the values to the subscriber are coming through while using receive(on: RunLoop.main) as expected.

Note: I am sorry I don't have a test device to test so couldn't test on a real device but simulator works as expected.

Simulator testing should be fine too! Thanks for verifying.

1 Like

Thanks a lot for the quick response.

I am experiencing the same issue. Specifically we are wanting to run a publisher that performs an expensive operation on a background thread while receiving the results on the main queue. It appears to be a bug in the framework but any workarounds are appreciated! (edit: read too fast and missed that this might be fixed in the Xcode 11.3 beta—will check there—thanks!)

Followup: I tested this against Xcode 11.3 beta 1 in Playgrounds and the issue is still present. Workarounds/fixes appreciated!

let a = PassthroughSubject<Int, Never>()
let b = PassthroughSubject<String, Never>()

let c = a
    .map { a -> Int in Date().addingTimeInterval(1))
        return a
    .receive(on: DispatchQueue.main)
let cancellable = Publishers.CombineLatest(b, c).sink {
    print("b, c", $0, $1)

1 Like

subscribe(on:) is now the one operator which does send the subscription asynchronously.

Hello, what is "now"? Does the Combine behavior change from one OS version to another? Is there some release notes that could help us developers adapt our Combine code depending on the OS version?

"now" is: as of iOS 13.3 (as noted above).

I'm working on the release note issue.

1 Like

Thank you! When we write apps or libraries, it's important to be aware of the various Combine flavors!

1 Like

You folks have been talking about iOS. How does all of this relate to macOS?


The change is present on all the aligned software updates for all platforms. iOS 13.3, watchOS 6.1.1, tvOS 13.3, and macOS 10.15.2. (Hope I got all those version numbers right).

the subscribe(on:) is still async on iOS 13.3.1 is there a workaround to reliably deliver the value downstream to sink ? using buffer in this case on iOS 13.2 works well but on iOS 13.3.1 doesn't work and the value doesn't get delivered at all times. And without using buffer: on iOS 13.2: sometimes the value got delivered and sometimes didn't deliver.
iOS 13.3.1: the value didn't get delivered all the times.

This issue (FB7298518) has been fixed in macOS 10.15.5 19F101. Failures are now correctly delayed.


I have similar problem now
Simulator iOS 16.2
Xcode Version 14.2 (14C18)
Mac OS 13.3 (22E252)

Example to reproduce:

var subscriptions: Set<AnyCancellable> = []

func test_CombineLatest() throws {

        let expectation = self.expectation(description: "Async call")

        let deferredPublisher = Deferred {
            Future<String, Never> { promise in
                Swift.print("promise A")

        let publisher1 = deferredPublisher

        let publisher2 = PassthroughSubject<String, Never>()

        .sink { value in
            Swift.print("CombineLatest: ", value)
        .store(in: &subscriptions)


        wait(for: [expectation], timeout: 4)

promise call before receive subscription
Sometimes it works