From dce942454b6b85c08fc58867f6e4d5506718e56f Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 4 Sep 2023 18:33:24 +0700 Subject: [PATCH] basichost: handle the SetProtocol error in NewStream (#2555) --- p2p/host/basic/basic_host.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/p2p/host/basic/basic_host.go b/p2p/host/basic/basic_host.go index 71ad396768..50ab8dfb08 100644 --- a/p2p/host/basic/basic_host.go +++ b/p2p/host/basic/basic_host.go @@ -666,7 +666,9 @@ func (h *BasicHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.I } if pref != "" { - s.SetProtocol(pref) + if err := s.SetProtocol(pref); err != nil { + return nil, err + } lzcon := msmux.NewMSSelect(s, pref) return &streamWrapper{ Stream: s,