Skip to content

Commit 934eb7e

Browse files
cjihrigjasnell
authored andcommittedOct 17, 2018
tls: prevent multiple connection errors
onConnectEnd(), which is called by TLSSocket, has a guard to prevent being called multiple times, but it does not prevent the OpenSSL error handler from being called, leading to multiple error events. This commit adds that piece of missing logic. PR-URL: #23636 Fixes: #23631 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Wyatt Preul <wpreul@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 6975639 commit 934eb7e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎lib/_tls_wrap.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,11 @@ function onocspresponse(resp) {
248248
function onerror(err) {
249249
const owner = this[owner_symbol];
250250

251-
if (owner._writableState.errorEmitted)
251+
if (owner._hadError)
252252
return;
253253

254+
owner._hadError = true;
255+
254256
// Destroy socket if error happened before handshake's finish
255257
if (!owner._secureEstablished) {
256258
// When handshake fails control is not yet released,
@@ -265,8 +267,6 @@ function onerror(err) {
265267
// Throw error
266268
owner._emitTLSError(err);
267269
}
268-
269-
owner._writableState.errorEmitted = true;
270270
}
271271

272272
function initRead(tls, wrapped) {

0 commit comments

Comments
 (0)