Closed rschmukler closed 7 years ago
If you check out GenStage.stream
, which a Flow as an Enumerable is, you will see that it hijacks the current process inbox. So you have the GenStage producer and the flow racing for the same messages in the process inbox. When you halt the flow, the messages it is not able to consume as a consumer remain in the box which are then consumed by the Flow. The approach of what you are trying to do is not going to work. Why don't you connect the consumer directly to the Flow?
When using a Flow as the enumerable for the events as a GenStage producer, the process can receive consumer messages causing it to error. Interestingly enough, most of the messages to get correctly routed to the consumer but there appears to be some issue with the producer also receiving them. It appears to be some sort of race case as removing the
Process.sleep
causes it to work fine for me on my machine. Additionally, the error seems to only happen at the beginning and then the events will run fine afterwards.Here is some example code that can recreate the issue:
Here is some of the error messages that come through: