Skip to content

Commit

Permalink
tls: prevent multiple connection errors
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cjihrig authored and jasnell committed Oct 17, 2018
1 parent 6975639 commit 934eb7e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,11 @@ function onocspresponse(resp) {
function onerror(err) {
const owner = this[owner_symbol];

if (owner._writableState.errorEmitted)
if (owner._hadError)
return;

owner._hadError = true;

// Destroy socket if error happened before handshake's finish
if (!owner._secureEstablished) {
// When handshake fails control is not yet released,
Expand All @@ -265,8 +267,6 @@ function onerror(err) {
// Throw error
owner._emitTLSError(err);
}

owner._writableState.errorEmitted = true;
}

function initRead(tls, wrapped) {
Expand Down

0 comments on commit 934eb7e

Please sign in to comment.