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,