Commit a28f6eb5 authored by Lucas Molas's avatar Lucas Molas

fix(network): impl: add timeout in newStreamToPeer call

parent 963dc8fd
...@@ -27,6 +27,7 @@ import ( ...@@ -27,6 +27,7 @@ import (
var log = logging.Logger("bitswap_network") var log = logging.Logger("bitswap_network")
var connectTimeout = time.Second * 5
var sendMessageTimeout = time.Minute * 10 var sendMessageTimeout = time.Minute * 10
// NewFromIpfsHost returns a BitSwapNetwork supported by underlying IPFS host. // NewFromIpfsHost returns a BitSwapNetwork supported by underlying IPFS host.
...@@ -312,7 +313,10 @@ func (bsnet *impl) SendMessage( ...@@ -312,7 +313,10 @@ func (bsnet *impl) SendMessage(
p peer.ID, p peer.ID,
outgoing bsmsg.BitSwapMessage) error { outgoing bsmsg.BitSwapMessage) error {
s, err := bsnet.newStreamToPeer(ctx, p) tctx, cancel := context.WithTimeout(ctx, connectTimeout)
defer cancel()
s, err := bsnet.newStreamToPeer(tctx, p)
if err != nil { if err != nil {
return err return err
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment