Skip to content

Commit cf47bb9

Browse files
ronagtargos
authored andcommittedApr 22, 2020
http: don't emit 'finish' after 'error'
PR-URL: #32276 Refs: #28710 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 7f5b89c commit cf47bb9

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed
 

‎lib/_http_outgoing.js

+1
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) {
727727
};
728728

729729
function onFinish(outmsg) {
730+
if (outmsg && outmsg.socket && outmsg.socket._hadError) return;
730731
outmsg.emit('finish');
731732
}
732733

‎test/parallel/test-tls-set-secure-context.js

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ function makeRequest(port, id) {
8282
headers: { id }
8383
};
8484

85+
let errored = false;
8586
https.get(`https://localhost:${port}`, options, (res) => {
8687
let response = '';
8788

@@ -95,7 +96,10 @@ function makeRequest(port, id) {
9596
resolve(response);
9697
}));
9798
}).on('error', (err) => {
99+
errored = true;
98100
reject(err);
101+
}).on('finish', () => {
102+
assert.strictEqual(errored, false);
99103
});
100104
});
101105
}

0 commit comments

Comments
 (0)
Please sign in to comment.