Skip to content

http: fix keep-alive socket reuse race in requestOnFinish#61710

Open
martinslota wants to merge 3 commits intonodejs:mainfrom
martinslota:fix-issue-60001
Open

http: fix keep-alive socket reuse race in requestOnFinish#61710
martinslota wants to merge 3 commits intonodejs:mainfrom
martinslota:fix-issue-60001

Conversation

@martinslota
Copy link

When the response ends before the request's 'finish' event fires, responseOnEnd() and requestOnFinish() can both call responseKeepAlive(), corrupting the socket that the agent may have already handed to another request.

This PR adds a !req.destroyed guard to requestOnFinish() so the second call is skipped when the socket has already been released.

Fixes #60001.

Relates to aws/aws-sdk-js-v3#6426.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run. labels Feb 6, 2026
@martinslota
Copy link
Author

The fix can also be backported to Node.js versions 19 and upwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Certain kinds of HTTPS requests hang due to a race condition around reused sockets

2 participants