diff --git a/api/agent/agent.go b/api/agent/agent.go index ede44c8f9..ee36af5ad 100644 --- a/api/agent/agent.go +++ b/api/agent/agent.go @@ -716,6 +716,9 @@ func callToHTTPRequest(ctx context.Context, call *call) (*http.Request, error) { if err != nil { return req, err } + // Set the context on the request to make sure transport and client handle + // it properly and close connections at the end, e.g. when using UDS. + req = req.WithContext(ctx) req.Header = make(http.Header) for k, vs := range call.req.Header {