diff --git a/lib/child_process.js b/lib/child_process.js index f3a5bdd7dc..8ff258ead1 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -117,11 +117,6 @@ function setupChannel(target, channel) { if (!target._channel) throw new Error("channel closed"); - // For overflow protection don't write if channel queue is too deep. - if (channel.writeQueueSize > 1024 * 1024) { - return false; - } - var buffer = Buffer(JSON.stringify(message) + '\n'); if (sendHandle && setSimultaneousAccepts) { @@ -137,7 +132,8 @@ function setupChannel(target, channel) { writeReq.oncomplete = nop; - return true; + /* If the master is > 2 read() calls behind, please stop sending. */ + return channel.writeQueueSize < (65536 * 2); }; channel.readStart();