-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open files after downloading image #181
Comments
Could reproduce this behavior on windows10. For
|
Shouldn't the fileWriteStream be closed within line ?https://github.com/tomas/needle/blob/master/lib/needle.js#L563 with out.on('end', function() {
// NEW: Close file here
file && file.end();
// we want to be able to access to the raw data later, so keep a reference.
resp.raw = Buffer.concat(resp.raw);
... |
Thanks @tbouchnafa for the report and @frankred for the debugging! Does the fix solve the issue? |
For me yes, but the needle implementation is too complex for me to understand completely. If this new line does not produce any side effects to other use cases then this is a solution. What do you mean @tomas. Best regards! |
Great. I'll do some tests and get it merged soon. |
Hm, according to the official docs:
Which means that unless there's some error on the stream object, it shouldn't be necessary to call
|
Not sure what your intention is but I get the following. Same problem. In my opinion the example do not create a seperate file descriptor?!
Maybe the problem is this special PassThrough mode:
|
Minified example:
|
Just fixed and pushed new version to npm. Thanks guys! |
Hi,
we are facing a problem using
needle
. We use needle to download several images within a web application. After downloading the images the file connections to local target path remain open.Running a webservice who downloads files for a couple of time will produce an error
too many open files
which has side effects to the health of the service.Dependencies:
You can reproduce this problem using the following code snippet:
And call the following resource
http://localhost:3300/download
once or several times:The output of
lsof | grep GitHub-Logo.png
after the file was successfully downloaded:We expect the read-/writestream of the file should be closed afterwards.
Regards
The text was updated successfully, but these errors were encountered: