How to close a readable stream (before end)?
Edit: Good news! Starting with Node.js 8.0.0 readable.destroy is officially available: https://nodejs.org/api/stream.html#stream_readable_destroy_error ReadStream.destroy You can call the ReadStream.destroy function at any time. var fs = require(“fs”); var readStream = fs.createReadStream(“lines.txt”); readStream .on(“data”, function (chunk) { console.log(chunk); readStream.destroy(); }) .on(“end”, function () { // This may not been called since we are destroying the stream // … Read more