diff --git a/examples/delegated-routing/package.json b/examples/delegated-routing/package.json index 8c7d4302..ddbbecc3 100644 --- a/examples/delegated-routing/package.json +++ b/examples/delegated-routing/package.json @@ -9,7 +9,7 @@ "@libp2p/delegated-content-routing": "^2.0.1", "@libp2p/delegated-peer-routing": "^2.0.1", "@libp2p/kad-dht": "^3.0.0", - "@libp2p/mplex": "^5.0.0", + "@libp2p/mplex": "^5.2.1", "@libp2p/webrtc-star": "^3.0.0", "@libp2p/websockets": "^3.0.0", "react": "^17.0.2", diff --git a/examples/libp2p-in-the-browser/package.json b/examples/libp2p-in-the-browser/package.json index f53ae096..23b00d21 100644 --- a/examples/libp2p-in-the-browser/package.json +++ b/examples/libp2p-in-the-browser/package.json @@ -11,7 +11,7 @@ "dependencies": { "@chainsafe/libp2p-noise": "^8.0.0", "@libp2p/bootstrap": "^2.0.0", - "@libp2p/mplex": "^5.0.0", + "@libp2p/mplex": "^5.2.1", "@libp2p/webrtc-star": "^3.0.0", "@libp2p/websockets": "^3.0.0", "libp2p": "../../" diff --git a/examples/webrtc-direct/package.json b/examples/webrtc-direct/package.json index d5be295f..e1bf6de6 100644 --- a/examples/webrtc-direct/package.json +++ b/examples/webrtc-direct/package.json @@ -12,7 +12,7 @@ "@libp2p/webrtc-direct": "^2.0.0", "@chainsafe/libp2p-noise": "^8.0.0", "@libp2p/bootstrap": "^2.0.0", - "@libp2p/mplex": "^5.0.0", + "@libp2p/mplex": "^5.2.1", "libp2p": "../../", "wrtc": "^0.4.7" }, diff --git a/package.json b/package.json index 074b7c76..b5f7f711 100644 --- a/package.json +++ b/package.json @@ -180,7 +180,7 @@ "@libp2p/interop": "^2.0.0", "@libp2p/kad-dht": "^3.0.4", "@libp2p/mdns": "^3.0.0", - "@libp2p/mplex": "^5.0.0", + "@libp2p/mplex": "^5.2.1", "@libp2p/pubsub": "^3.0.1", "@libp2p/tcp": "^3.0.5", "@libp2p/topology": "^3.0.0", diff --git a/src/upgrader.ts b/src/upgrader.ts index bc0a8d96..23159d03 100644 --- a/src/upgrader.ts +++ b/src/upgrader.ts @@ -440,20 +440,17 @@ export class DefaultUpgrader extends EventEmitter implements Upg throw err } - muxedStream.stat.protocol = protocol - // If a protocol stream has been successfully negotiated and is to be passed to the application, // the peerstore should ensure that the peer is registered with that protocol this.components.getPeerStore().protoBook.add(remotePeer, [protocol]).catch(err => log.error(err)) - return { - ...muxedStream, - ...stream, - stat: { - ...muxedStream.stat, - protocol - } - } + // after the handshake the returned stream can have early data so override + // the souce/sink + muxedStream.source = stream.source + muxedStream.sink = stream.sink + muxedStream.stat.protocol = protocol + + return muxedStream } catch (err: any) { log.error('could not create new stream', err)