NodeFly / uhura

Server-to-server event emitter with session support
MIT License
19 stars 5 forks source link

Stalls with big payloads #6

Closed bnoordhuis closed 10 years ago

bnoordhuis commented 10 years ago
var N = process.argv[2] | 0 || 1024;  // size in kb
var U = require('uhura');

var server = U.createServer(onConnection);
server.listen(4567, createConnection);

function onConnection(socket, reconnect) {
  socket.socket.on('data', function(data) {
    console.log(data.length);
  });
  socket.on('test', function(data) {
    server.close();
    socket.disconnect();
  });
}

function createConnection() {
  var socket = U.createClient();
  socket.connect(4567);
  socket.once('connect', function() {
    socket.send('test', Array(N << 10).join('.'));
    socket.disconnect();
  });
}

Example output on OS X:

$ node t.js 183
63
65536
65536
56386
# exits by itself

$ node t.js 184
63
65536
65536
56876
# hangs

On two of my Linux machines, the magic cutoff point appears to be 641 kB. Needs further investigation.