Skip to content

fix(http): handle socket-only request errors without leaking keep-alive listeners#10576

Merged
jasonsaayman merged 2 commits intoaxios:v1.xfrom
raashish1601:contributor-10/axios-10558-v1x
Apr 8, 2026
Merged

fix(http): handle socket-only request errors without leaking keep-alive listeners#10576
jasonsaayman merged 2 commits intoaxios:v1.xfrom
raashish1601:contributor-10/axios-10558-v1x

Conversation

@raashish1601
Copy link
Copy Markdown
Contributor

@raashish1601 raashish1601 commented Mar 28, 2026

Summary

  • route request socket-only failures through
    eq.destroy(err) so Axios rejects instead of leaving the error outside the request promise chain
  • remove the per-request socket error listener on
    eq.close so reused keep-alive sockets do not accumulate listeners
  • add focused adapter regressions for socket-only request errors and keep-alive listener cleanup

Notes

Closes #10558


Summary by cubic

Ensure axios rejects when a request’s socket emits an error, and prevent keep-alive listener leaks by removing per-request socket error listeners on close. Adds unit tests for the socket-only error path and listener cleanup. Addresses #10558.

Description

  • Route socket-only errors through req.destroy(err) so requests reject.
  • Add a per-request socket.on('error', ...) and remove it on req.once('close', ...) to avoid leaks on reused keep-alive sockets.
  • Matches Node keep-alive behavior and prevents unhandled socket errors during reuse.

Testing

  • Added tests in tests/unit/adapters/http.test.js:
    • Rejects when only the request socket emits an error.
    • Confirms socket error listeners are removed after each keep-alive request (listener count stays constant).

Written for commit 77eef87. Summary will update on new commits.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@jasonsaayman jasonsaayman force-pushed the contributor-10/axios-10558-v1x branch from c95c5ad to 77eef87 Compare April 8, 2026 19:47
@jasonsaayman jasonsaayman merged commit 8b68491 into axios:v1.x Apr 8, 2026
21 of 28 checks passed
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.

Failed requests can sometimes crash the Node.js process with EPIPE.

2 participants