Readable stream cleanup issues.
Steps to reproduce:
- Run
node leaks.js
- Issue a request to it, for example via
curl http://localhost:3000
- Watch
leaks.js
repeatedly print_read <Date>
to the console while the request is active - Kill the request by killing curl
leaks.js
still keeps printing_read <Date>
. The readable stream is still being read although the request ended
Fixed in fixed.js
by implementing and calling a custom closing mechanism. The fact that we have to call the .close()
manually means that if you just fs.createReadStream("/dev/random").pipe(res)
you create a leak again.
Same in node 0.10 and 0.11.