Skip to content

Commit

Permalink
Syntax and header
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas committed Dec 8, 2023
1 parent e045301 commit ba3bc2e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/needle.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//////////////////////////////////////////
// Needle -- HTTP Client for Node.js
// Written by Tomás Pollak <tomas@forkhq.com>
// (c) 2012-2020 - Fork Ltd.
// (c) 2012-2023 - Fork Ltd.
// MIT Licensed
//////////////////////////////////////////

Expand Down Expand Up @@ -780,12 +780,11 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data,
request.end();
}

// Manage the abort signal
if (signal) {
if (signal) { // abort signal given, so handle it
if (signal.aborted === true) {
abort_handler();
} else {
signal.addEventListener('abort', abort_handler, {once: true});
signal.addEventListener('abort', abort_handler, { once: true });
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/errors_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ describe('errors', function() {

needle.get(url, { timeout: 300 }, cb);
needle.get(url, { timeout: 350 }, cb);
needle.get(url, { timeout: 400}, cb);
needle.get(url, { timeout: 400 }, cb);

function abort() {
cancel.abort();
Expand Down

0 comments on commit ba3bc2e

Please sign in to comment.