From b037bca9786a65344f76b245eb7a8361a124b0de Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Mon, 21 Sep 2015 19:22:26 -0400 Subject: [PATCH] tls: use parent handle's close callback When closing the child TLSWrap handle - wait for the proper parent's handle close callback invocation. `uv_close_cb` may be invoked much later than the next libuv tick, depending on the platform. Fix: https://github.com/nodejs/node/issues/2979 --- lib/_tls_wrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 1bff7579fc2914..ae88bf6c18ebf6 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);