From 146bea1c14e19c75c6a89c7c493ee14ebd110452 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sat, 2 May 2015 17:32:29 +0200 Subject: [PATCH] net: ensure WriteWrap references the handle `StreamBase::AfterWrite` is passing handle as an argument to the `afterWrite` function in net.js. Thus GC should not collect the handle and the request separately and assume that they are tied together. With this commit - request will always outlive the StreamBase instance, helping us survive the GC pass. Fix: /~https://github.com/iojs/io.js/pull/1580 --- lib/net.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/net.js b/lib/net.js index 867e1df7ccc252..0e0060f07da17a 100644 --- a/lib/net.js +++ b/lib/net.js @@ -627,6 +627,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) { } var req = new WriteWrap(); + req.handle = this._handle; req.oncomplete = afterWrite; req.async = false; var err;