From 721ef83bda991719596aec70f71badcc236f5579 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Mon, 21 Mar 2022 19:11:33 -0700 Subject: [PATCH] fix: Fix test failures in node v4-v12 These failures were introduced by PR #392 Rather than abort the request, set up a listener to silence any errors thrown late, as happens on macOS in certain node versions. Closes #397 --- lib/needle.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/needle.js b/lib/needle.js index 2652827a5..bf28ecf9a 100644 --- a/lib/needle.js +++ b/lib/needle.js @@ -490,12 +490,11 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data, out.done = true; // An error can still be fired after closing. In particular, on macOS. - // Adding an explicit abort() call resolves this without leaving a dangling - // listener. See also: + // See also: // - https://github.com/tomas/needle/issues/391 // - https://github.com/less/less.js/issues/3693 // - https://github.com/nodejs/node/issues/27916 - request.abort(); + request.once('error', function() {}); if (callback) return callback(err, resp, resp ? resp.body : undefined);