toolkit icon indicating copy to clipboard operation
toolkit copied to clipboard

fix(tool-cache): enable keepAlive for HTTP client to improve download reliability

Open v1sion opened this issue 7 months ago • 1 comments

This PR updates the httpm.HttpClient initialization in the tool-cache package to explicitly set keepAlive: true when downloading tools.

The HTTP client is being created without specifying the keepAlive option, which defaults to false.

https://github.com/actions/toolkit/blob/main/packages/http-client/src/index.ts#L142 https://github.com/actions/toolkit/blob/main/packages/http-client/src/index.ts#L172

This causes the client to open a new TCP connection for every request and close it immediately after. In some environments, especially those involving network proxies or service meshes, this pattern can lead to unreliable downloads, connection resets, or timeouts, as these systems often expect clients to reuse connections.

Eg: Screenshot 2025-06-20 at 09 50 37

By setting keepAlive: true, the HTTP client will reuse TCP connections for multiple requests.

v1sion avatar Jun 20 '25 12:06 v1sion