From 39e81ec2bc4f0599a47fba97e9616ce2c41fe809 Mon Sep 17 00:00:00 2001 From: Daniel Norman <1992255+2color@users.noreply.github.com> Date: Mon, 5 Aug 2024 15:50:18 +0200 Subject: [PATCH 1/3] fix: increase bitswap connection timeout --- bitswap/network/ipfs_impl.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitswap/network/ipfs_impl.go b/bitswap/network/ipfs_impl.go index ac9ab66a6..6b2c476c3 100644 --- a/bitswap/network/ipfs_impl.go +++ b/bitswap/network/ipfs_impl.go @@ -28,7 +28,7 @@ import ( var log = logging.Logger("bitswap/network") -var connectTimeout = time.Second * 5 +var connectTimeout = time.Second * 10 var ( maxSendTimeout = 2 * time.Minute From 9a14d245e5e84064b8e75d1dd4092b959ca2e6cb Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 6 Aug 2024 20:42:29 +0200 Subject: [PATCH 2/3] refactor: remove hardcoded timeout connectionTimeout here is not necessary since defaultNewStreamTimeout was introduced upstream in https://github.com/libp2p/go-libp2p/pull/2907 --- bitswap/network/ipfs_impl.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/bitswap/network/ipfs_impl.go b/bitswap/network/ipfs_impl.go index 6b2c476c3..7acc3abcc 100644 --- a/bitswap/network/ipfs_impl.go +++ b/bitswap/network/ipfs_impl.go @@ -28,8 +28,6 @@ import ( var log = logging.Logger("bitswap/network") -var connectTimeout = time.Second * 10 - var ( maxSendTimeout = 2 * time.Minute minSendTimeout = 10 * time.Second @@ -323,10 +321,7 @@ func (bsnet *impl) SendMessage( p peer.ID, outgoing bsmsg.BitSwapMessage, ) error { - tctx, cancel := context.WithTimeout(ctx, connectTimeout) - defer cancel() - - s, err := bsnet.newStreamToPeer(tctx, p) + s, err := bsnet.newStreamToPeer(ctx, p) if err != nil { return err } From e65d9b86a6edbe608b2b61f368e9c5e5273c1b6b Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 6 Aug 2024 21:03:13 +0200 Subject: [PATCH 3/3] docs: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1be6d134..08dc79583 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ The following emojis are used to highlight certain changes: - `boxo/gateway` now correctly returns 404 Status Not Found instead of 500 when the requested content cannot be found due to offline exchange, gateway running in no-fetch (non-recursive) mode, or a similar restriction that only serves a specific set of CIDs. - `bitswap/client` fix memory leak in BlockPresenceManager due to unlimited map growth. +- `bitswap/network` fixed race condition when a timeout occurred before hole punching completed while establishing a first-time stream to a peer behind a NAT ### Security