tomas / needle

Nimble, streamable HTTP client for Node.js. With proxy, iconv, cookie, deflate & multipart support.

Home Page:https://www.npmjs.com/package/needle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ECONNRESET thrown after connection closed

joeyparrish opened this issue · comments

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.

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.