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

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

Merged
merged 1 commit into from
Apr 23, 2021

Conversation

schomatis
Copy link
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 self-assigned this Apr 22, 2021
Comment on lines +316 to +317
tctx, cancel := context.WithTimeout(ctx, connectTimeout)
defer cancel()
Copy link
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
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
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.

Copy link
Member

@Stebalien Stebalien left a comment

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 on lines +316 to +317
tctx, cancel := context.WithTimeout(ctx, connectTimeout)
defer cancel()
Copy link
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