Skip to content

Commit ed0a97a

Browse files
cjihrigMylesBorins
authored andcommitted
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 4b98ff2 commit ed0a97a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/_tls_wrap.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,11 @@ function onocspresponse(resp) {
250250
function onerror(err) {
251251
const owner = this[owner_symbol];
252252

253-
if (owner._writableState.errorEmitted)
253+
if (owner._hadError)
254254
return;
255255

256+
owner._hadError = true;
257+
256258
// Destroy socket if error happened before handshake's finish
257259
if (!owner._secureEstablished) {
258260
// When handshake fails control is not yet released,
@@ -267,8 +269,6 @@ function onerror(err) {
267269
// Throw error
268270
owner._emitTLSError(err);
269271
}
270-
271-
owner._writableState.errorEmitted = true;
272272
}
273273

274274
function initRead(tls, wrapped) {

0 commit comments

Comments
 (0)