AsyncPublisher causes crash in rather simple situation

I finally managed to reduce the crash I was experiencing down to the following:

let a = ObservableObjectPublisher()
Task {
    try await Task.sleep(nanoseconds: 1_000_000)
await AsyncPublisher(a).first(where: { _ in true })

which produces the error message: Received an output without requesting demand:

I suppose this is a bug in Combine, so I'll also file a bug report to Apple, but if anyone can help me understand this better so that I can work around it that would be great, because it's problematic for me that after awaiting the publisher in this way I can no longer publish to it without provoking a crash.


1 Like

That is definitely a bug; it seems like ObservableObjectPublisher is not properly respecting demand. Do you happen to have a feedback # on it?

I think this is the feedback number? FB9975196

Got it routed to the right spot; it looks like ObservableObjectPublisher is expecting everything subscribed to it to be unlimited, I would suggest instead to use a PassthroughSubject instead if possible - that will respect demand correctly.

1 Like