Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
fix(network): impl: add timeout in newStreamToPeer call
Browse files Browse the repository at this point in the history
  • Loading branch information
schomatis committed Apr 22, 2021
1 parent 963dc8f commit a28f6eb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion network/ipfs_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

var log = logging.Logger("bitswap_network")

var connectTimeout = time.Second * 5
var sendMessageTimeout = time.Minute * 10

// NewFromIpfsHost returns a BitSwapNetwork supported by underlying IPFS host.
Expand Down Expand Up @@ -312,7 +313,10 @@ func (bsnet *impl) SendMessage(
p peer.ID,
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 {
return err
}
Expand Down

0 comments on commit a28f6eb

Please sign in to comment.