-
Notifications
You must be signed in to change notification settings - Fork 7.3k
CreateReadStream doesn't close the file #9429
Comments
if i use code like : var fs = require('fs');
var http = require('http');
var server = http.Server(function(req, res) {
var content = fs.createReadStream('power.log');
content.pipe(res);
});
server.listen(9999); and when i use wrk for press testing.i got the same problem as you got.
but,when i change code to: var fs = require('fs');
var http = require('http');
var server = http.Server(function(req, res) {
var content = fs.createReadStream('power.log');
content.pipe(res);
content.on('end', function() {
content.close();
});
});
server.listen(9999); it did not happen. but i am not sure whether i do it on correct way. |
@petersirka can you give a test case that demonstrates what you're doing when you see the problem? @dayuoba's response is useful but it would be easier to see what you did in particular to bring out the issue. |
@jasnell I have created a video for Example: Thanks. |
Can I bump this? |
could this be related? |
I've encountered this too. |
@danielgindi can you open up a new issue on https://github.com/nodejs/node, with an example on how to reproduce? |
I think this problem can really be solved by using http://npm.im/pump instead of I'm closing this, but feel free to open a new issue. |
@mcollina It would be a rather complicated example. It does not happen in the simple cases that were demonstrated in this issue. It actually happens when there are more users of the same |
@danielgindi thanks! Be sure you are using a supported version of node. |
I found a big problem in streams. I performed multiple tests on Ubuntu 14.04 LTS and OSX too and I see multiple opened files through
lsof -p PID
. I useautoClose: true
(in default) and I destroy the stream manually with this module https://github.com/stream-utils/destroy.This problem is not recorded for every request, but only if I performed multiple requests at the same time. My website falls down.
How can I prevent this problem? Is there a bug? How to close opened files? Extending
ulimit
is not a solution.Thanks for any advice.
PS: node v0.12.0
The text was updated successfully, but these errors were encountered: