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

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

Merged
Stebalien merged 1 commit into
masterfrom
schomatis/impl/newStreamToPeer-with-timeout
Apr 23, 2021
Merged

fix(network): impl: add timeout in newStreamToPeer call#477
Stebalien merged 1 commit into
masterfrom
schomatis/impl/newStreamToPeer-with-timeout

Conversation

@schomatis

Copy link
Copy Markdown
Contributor

See ipfs/kubo#7972 (comment) for background.

If there is a straightforward 10-line way to test this I can add it, otherwise I'll just leave the fix.

@schomatis schomatis requested a review from Stebalien April 22, 2021 14:32
@schomatis schomatis self-assigned this Apr 22, 2021
Comment thread network/ipfs_impl.go
Comment on lines +316 to +317
tctx, cancel := context.WithTimeout(ctx, connectTimeout)
defer cancel()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken from:

tctx, cancel := context.WithTimeout(ctx, s.opts.SendTimeout)
defer cancel()
if err := s.bsnet.ConnectTo(tctx, s.to); err != nil {
return nil, err
}
stream, err := s.bsnet.newStreamToPeer(tctx, s.to)
if err != nil {
return nil, err
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, I'm not setting the timeout inside newStreamToPeer or as an argument (like msgToStream does) because the current pattern in Connect is embedding the timeout externally in the context passed to newStreamToPeer. But I can change both if we want to go in another direction.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably fine for now.

@Stebalien Stebalien left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to eventually deduplicate our two different message sending functions... But whatever...

Comment thread network/ipfs_impl.go
Comment on lines +316 to +317
tctx, cancel := context.WithTimeout(ctx, connectTimeout)
defer cancel()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably fine for now.

@Stebalien Stebalien merged commit c13e78b into master Apr 23, 2021
@schomatis schomatis deleted the schomatis/impl/newStreamToPeer-with-timeout branch April 23, 2021 00:57
Jorropo pushed a commit to Jorropo/go-libipfs that referenced this pull request Jan 26, 2023
…reamToPeer-with-timeout

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

This commit was moved from ipfs/go-bitswap@c13e78b
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants