Skip to content

Commit ea27fc4

Browse files
committed
http: ignore multiple abort
1 parent 440a344 commit ea27fc4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/_http_client.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,12 @@ ClientRequest.prototype._implicitHeader = function _implicitHeader() {
312312
};
313313

314314
ClientRequest.prototype.abort = function abort() {
315-
if (!this.aborted) {
316-
process.nextTick(emitAbortNT.bind(this));
315+
if (this.aborted) {
316+
return;
317317
}
318+
318319
this.aborted = true;
320+
process.nextTick(emitAbortNT.bind(this));
319321

320322
// If we're aborting, we don't care about any more response data.
321323
if (this.res) {

test/parallel/test-http-client-abort2.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ const server = http.createServer(common.mustCall((req, res) => {
3030
server.listen(0, common.mustCall(() => {
3131
const options = { port: server.address().port };
3232
const req = http.get(options, common.mustCall((res) => {
33+
res._dump = common.mustCall(res._dump.bind(res));
3334
res.on('data', (data) => {
35+
req.abort();
3436
req.abort();
3537
server.close();
3638
});

0 commit comments

Comments
 (0)