Skip to content

Deadlock when throwing error from FlatMap in connectable observable #280

@kyle-hiller-nh

Description

@kyle-hiller-nh

I am trying to use a connectable observable to allow multiple observers to watch some data and transform it. If an error occurs in the observable, I would like to use the StopOnError functionality to stop the whole pipeline. However, whenever I throw an error from the FlatMap operation in this observable, the program deadlocks in goparkwith waitReason: waitReasonChanReceive. It seems like a channel is waiting to receive the error but there is nothing ever sent to it? I do not understand the implementation of Connectable observables well enough to know why this might be the case.

I have tried multiple ways of creating the Error like rxgo.Thrown(err), rxgo.FromChannel(rxgo.JustItem(rxgo.Error(err)).Observe()), manually creating a channel and putting the error item onto it, etc.

Is this a bug? Is there some way to work around this?

To Reproduce

  1. Create an Observable using FromChannel()
  2. Create a Connectable observable by calling FlatMap on an observable and passing the rxgo.WithPublishStrategy() option.
  3. Make the FlatMap operation throw an error
  4. Create an observer of this observable
  5. call Connect()on the observable
  6. Try get an item from the Observer (e.g. First())
  7. Deadlock

Expected behavior
The program should not deadlock and the Observer should resolve to the error.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions