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 MylesBorins committed Nov 29, 2018
1 parent 4b98ff2 commit ed0a97a
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 @@ -250,9 +250,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 @@ -267,8 +269,6 @@ function onerror(err) {
// Throw error
owner._emitTLSError(err);
}

owner._writableState.errorEmitted = true;
}

function initRead(tls, wrapped) {
Expand Down

0 comments on commit ed0a97a

Please sign in to comment.