Mpsc Receiver getting dropped after being passed into a futures combinator


So I’m writing this plugin for a program that facilitates websockets. I’ve almost finished but I hit a brick wall with a receiver getting dropped.

Basically, there are two channels, one is a stdlib one that simply acts as a queue when new data arrives, so the host app’s event loop can query it and trigger callbacks. The second one is for when the host app needs to send data on the websocket.

The problem is, this one is somehow getting dropped and I get this error at runtime:

send failed because receiver is gone

On this line:

where the host app calls to send some data to the channel which is consumed by the futures combinator spaghetti.

I’ve been trying to figure this one out for a while now - I thought my combinator code was wrong so I even rewrote the entire thing but I can’t seem to solve it. I don’t know how the receiver is being dropped, it’s moved into the combinator closure and used to forward data to the stream sink.

Would love to get this last piece of the puzzle solved, thanks!


This looks off - you should not be wait()'ing for a future inside your chain of futures. Instead, that future (or some continuation on top of it) needs to be fed to the event loop/reactor, and let it run it to completion.

As it happens, I think your entire and_then just completes, and the receiver is dropped.