Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: docs for Dial and DialContext should indicate concurrency properties #25019

jsha opened this issue Apr 23, 2018 · 2 comments


None yet
4 participants
Copy link

commented Apr 23, 2018

In Go 1.10.1, a user of the net/http package can specify a custom RoundTripper. That RoundTripper can define a custom Dial and/or DialContext. When running Client.Do, the Dial or DialContext function is run on a separate goroutine. If the function has side effects (for instance, recording its results in a shared slice), this can cause race conditions. For a real-world example, see letsencrypt/boulder#3109.

I think the documentation should be updated to mention that Dial and DialContext may be run concurrently with the function calling Client.Do. Here's the current documenation:

// DialContext specifies the dial function for creating unencrypted TCP connections.
// If DialContext is nil (and the deprecated Dial below is also nil),
// then the transport dials using package net.
DialContext func(ctx context.Context, network, addr string) (net.Conn, error)

// Dial specifies the dial function for creating unencrypted TCP connections.
// Deprecated: Use DialContext instead, which allows the transport
// to cancel dials as soon as they are no longer needed.
// If both are set, DialContext takes priority.
Dial func(network, addr string) (net.Conn, error)



This comment has been minimized.

Copy link

commented Apr 23, 2018

@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Apr 23, 2018


This comment has been minimized.

Copy link

commented Jun 5, 2018

Change mentions this issue: net/http: document Transport.Dial concurrency

@bradfitz bradfitz self-assigned this Jun 5, 2018

@gopherbot gopherbot closed this in db49f76 Jun 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.