Skip to content

fix(web): configure shared servers once before serving listeners - #454

Open
siavashs wants to merge 1 commit into
prometheus:masterfrom
siavashs:fix/configure-once-before-serve
Open

siavashs wants to merge 1 commit into
prometheus:masterfrom
siavashs:fix/configure-once-before-serve

Conversation

@siavashs

@siavashs siavashs commented Oct 6, 2026

Copy link
Copy Markdown

ServeMultiple calls Serve concurrently for each listener on the same http.Server.
Repeated setup can wrap the handler more than once and race when updating the handler and TLS configuration.

Configure middleware and TLS once before starting listener goroutines.
Preserve the public APIs and the existing wait-for-all return behavior.

@SoloJacobs SoloJacobs left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, some minor comments. I'm a bit sad that we can't fix the signature to just be correct, i.e.,

func New(handler http.Handler, cfg *Config) (*http.Server, error) {

Comment thread web/tls_protocols_test.go Outdated
Comment thread web/tls_config.go Outdated
Comment thread web/tls_config.go
@siavashs
siavashs force-pushed the fix/configure-once-before-serve branch 2 times, most recently from 73ac568 to da48107 Compare October 9, 2026 14:28
@SoloJacobs

Copy link
Copy Markdown

LGTM, very nice ! the golanglint-ci issues seem pre-existing?

@siavashs

siavashs commented Oct 9, 2026

Copy link
Copy Markdown
Author

@SuperQ should we fix the golangci-lint issue in this PR or separately?

@SoloJacobs

Copy link
Copy Markdown

#455 Probably fixed this issue, @siavashs let's rebase.

ServeMultiple calls Serve concurrently for each listener on the same
http.Server. Repeated setup can wrap the handler more than once and
race when updating the handler and TLS configuration.

Configure middleware and TLS once before starting listener goroutines.
Preserve the public APIs and the existing wait-for-all return behavior.

Signed-off-by: Siavash Safi <siavash@cloudflare.com>
@siavashs
siavashs force-pushed the fix/configure-once-before-serve branch from da48107 to a28aa2a Compare October 10, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants