tomas / needle

Nimble, streamable HTTP client for Node.js. With proxy, iconv, cookie, deflate & multipart support.
https://www.npmjs.com/package/needle
MIT License
1.63k stars 236 forks source link

ECONNRESET thrown after connection closed #391

Closed joeyparrish closed 2 years ago

joeyparrish commented 2 years ago

less v4 uses needle for https requests. It fails with ECONNRESET on macOS specifically, which is reproducible in GitHub Actions as well as on our private mac hardware. The failure is caused by an ECONNRESET error after the connection is closed.

Details can be found here:

The node discussion includes a workaround, which is that you can call abort() explicitly after closing the connection. I will send a PR with that fix shortly.

alolis commented 2 years ago

abort is deprecated since node.js v13.14.0 as per the documentation here. destroy should be used instead.

However, I am not sure if this is the correct approach here. Maybe the error listener should be removed AFTER the socket has been destroyed instead of explicitly aborting/destroying it.