diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 06b555a1254cbe..4ad79cf7a28d15 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -300,12 +300,16 @@ var proxiedMethods = [ ]; // Proxy HandleWrap, PipeWrap and TCPWrap methods -proxiedMethods.forEach(function(name) { - tls_wrap.TLSWrap.prototype[name] = function methodProxy(...args) { +function makeMethodProxy(name) { + return function methodProxy(...args) { if (this._parent[name]) return this._parent[name].apply(this._parent, args); }; -}); +} +for (var n = 0; n < proxiedMethods.length; n++) { + tls_wrap.TLSWrap.prototype[proxiedMethods[n]] = + makeMethodProxy(proxiedMethods[n]); +} tls_wrap.TLSWrap.prototype.close = function close(cb) { let ssl;