Leaked socket in cache/internal/cacheHttpClient
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
https://github.com/actions/cache/pull/1217 attempted to work around a dangling socket, which became especially apparent when that action migrated to Node 20, as Node v20 started keeping connection alive by default.
This solution worked for actions/cache in the meantime, but caused downstream consumers of to implement the same logic to avoid hanging processes and generated similar issues, such as:
The leaked socket originates in cache/src/internal/cacheHttpClient:
const uploadChunkResponse = await retryHttpClientResponse(
`uploadChunk (start: ${start}, end: ${end})`,
async () =>
httpClient.sendStream(
'PATCH',
resourceUrl,
openStream(),
additionalHeaders
)
)
sendStream return a response, the body of must be consumed to avoid holding the event loop open.
Something like the following ought to do it:
const uploadChunkResponse = await retryHttpClientResponse(
`uploadChunk (start: ${start}, end: ${end})`,
async () => {
const response = await httpClient.sendStream(
'PATCH',
resourceUrl,
openStream(),
additionalHeaders
)
await response.readBody()
return response
}
)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in cache/src/internal/cacheHttpClient at the uploadChunk call to httpClient.sendStream and inspect how its response is handled. Ensure the response body is consumed before returning, then verify that cache uploads no longer leave a socket holding the event loop open.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100