tomas / tomas/needle

Memory leak when writeStream close/error

Open
#280 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.6k
Forks
237
PR merge metrics
No merged PRs in 30d

Description

Hi @tomas ,

We have tried with below code and file descriptor remains opens.

var os = require('os');
var fs = require('fs');
var path = require('path');
var needle = require('needle');

var url = 'https://sample-videos.com/video123/mp4/360/big_buck_bunny_360p_30mb.mp4';
var output_path = path.join(__dirname, path.basename(url) + Math.random().toString());

var writeStream = fs.createWriteStream(output_path);

var readStream = needle.get(url);
readStream.pipe(writeStream);

setTimeout(function () {
    writeStream.close();
}, 2000);

//to keep the server alive for few mins
setTimeout(function () {
}, 99999999);

We are using needle version 2.4.0, node version v10.15.3 and OS version Ubuntu 16.04.6 LTS

I have checked with lsof -i -n -l -P -s -T qs | grep node command and its remain open.

Selection_168

I think it is very serious memory leak issue if we are using needle in large scale.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reproduction snippet with the listed Needle, Node.js, and Ubuntu versions, then inspect how the HTTP read stream and fs write stream behave on close and error. Confirm the file descriptor is released in both cases and add or run a regression test covering the reported lifecycle.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.