Skip to content

fd leak #55

@rlidwka

Description

@rlidwka

Something isn't right here:

var http = require('http');
var send = require('send');

var app = http.createServer(function(req, res){
  send(req, __filename).pipe(res);
}).listen(3000);


var net = require('net');
var headers = [
    'GET / HTTP/1.1',
    'Host: localhost:3000',
    '',
    ''
  ].join('\r\n');

function sendCanceledRequest () {
  var socket = new net.Socket();
  socket.connect(3000, 'localhost', function() {
    socket.write(headers, 'utf-8', function () {
        socket.destroy();
    });
  });
}

setInterval(sendCanceledRequest, 1000);
$ lsof -p `pidof node`
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
node    6327 alex  cwd    DIR   0,20      358     276 /tmp
node    6327 alex  rtd    DIR   0,20      226     256 /
node    6327 alex  txt    REG   0,20  1462424  185784 /usr/bin/nodejs
[... tons of system stuff skipped ...]
node    6327 alex    9u  0000    0,9        0    7445 anon_inode
node    6327 alex   10r   DIR   0,20      226     256 /
node    6327 alex   11u  IPv4  83502      0t0     TCP *:3000 (LISTEN)
node    6327 alex   12r   REG   0,20      540 1042412 /tmp/test1.js
node    6327 alex   13r   REG   0,20      540 1042412 /tmp/test1.js
node    6327 alex   14r   REG   0,20      540 1042412 /tmp/test1.js
node    6327 alex   15r   REG   0,20      540 1042412 /tmp/test1.js
node    6327 alex   16r   REG   0,20      540 1042412 /tmp/test1.js
node    6327 alex   17r   REG   0,20      540 1042412 /tmp/test1.js
node    6327 alex   18r   REG   0,20      540 1042412 /tmp/test1.js
node    6327 alex   19r   REG   0,20      540 1042412 /tmp/test1.js
[... tons of leaking fds skipped ...]
node    6327 alex   43r   REG   0,20      540 1042412 /tmp/test1.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions