diff --git a/libp2p/muxers/mplex.nim b/libp2p/muxers/mplex.nim index 31e2067cf..1e3d93d8d 100644 --- a/libp2p/muxers/mplex.nim +++ b/libp2p/muxers/mplex.nim @@ -44,6 +44,7 @@ type closedLocal*: bool closedRemote*: bool mplex*: Mplex + handlerFuture*: Future[void] proc newMplexUnknownMsgError*(): ref MplexUnknownMsgError = result = newException(MplexUnknownMsgError, "Unknown mplex message type") @@ -136,7 +137,7 @@ proc handle*(m: Mplex): Future[void] {.async, gcsafe.} = case msgType: of MessageType.New: let channel = await m.newStreamInternal(false, id.int) - await m.streamHandler(newConnection(channel)) + channel.handlerFuture = m.streamHandler(newConnection(channel)) of MessageType.MsgIn, MessageType.MsgOut: let channel = m.getChannelList(initiator)[id.int] let msg = await m.connection.readLp()