diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 1bff7579fc..ae88bf6c18 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -296,7 +296,7 @@ proxiedMethods.forEach(function(name) { tls_wrap.TLSWrap.prototype.close = function closeProxy(cb) { if (this._parentWrap && this._parentWrap._handle === this._parent) { - setImmediate(cb); + this._parentWrap.once('close', cb); return this._parentWrap.destroy(); } return this._parent.close(cb);