Quantcast
Channel: How to close a readable stream (before end)? - Stack Overflow
Browsing latest articles
Browse All 11 View Live

Answer by MalaviyRavi for How to close a readable stream (before end)?

for stop callback execution after some call,you have to use process.kill with particular processIDconst csv = require('csv-parser');const fs = require('fs');const filepath = "./demo.csv"let readStream...

View Article



Answer by DevTheJo for How to close a readable stream (before end)?

Today, in Node 10readableStream.destroy()is the official way to close a readable streamsee https://nodejs.org/api/stream.html#stream_readable_destroy_error

View Article

Answer by Rocco Musolino for How to close a readable stream (before end)?

This destroy module is meant to ensure a stream gets destroyed, handling different APIs and Node.js bugs. Right now is one of the best choice.NB. From Node 10 you can use the .destroy method without...

View Article

Answer by g00dnatur3 for How to close a readable stream (before end)?

This code here will do the trick nicely:function closeReadStream(stream) { if (!stream) return; if (stream.close) stream.close(); else if (stream.destroy) stream.destroy();}writeStream.end() is the...

View Article

Answer by Vexter for How to close a readable stream (before end)?

It's an old question but I too was looking for the answer and found the best one for my implementation. Both end and close events get emitted so I think this is the cleanest solution.This will do the...

View Article


Answer by Jacob Lowe for How to close a readable stream (before end)?

At version 4.*.* pushing a null value into the stream will trigger a EOF signal.From the nodejs docsIf a value other than null is passed, The push() method adds a chunk of data into the queue for...

View Article

Answer by Sayem for How to close a readable stream (before end)?

You can clear and close the stream with yourstream.resume(), which will dump everything on the stream and eventually close it.From the official docs:readable.resume():Return: thisThis method will cause...

View Article

Answer by thejoshwolfe for How to close a readable stream (before end)?

You can't. There is no documented way to close/shutdown/abort/destroy a generic Readable stream as of Node 5.3.0. This is a limitation of the Node stream architecture.As other answers here have...

View Article


Answer by Yves M. for 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_errorReadStream.destroyYou can call the...

View Article


Answer by Nitzan Shaked for How to close a readable stream (before end)?

Invoke input.close(). It's not in the docs, buthttps://github.com/joyent/node/blob/cfcb1de130867197cbc9c6012b7e84e08e53d032/lib/fs.js#L1597-L1620clearly does the job :) It actually does something...

View Article

How to close a readable stream (before end)?

How to close a readable stream in Node.js?var input = fs.createReadStream('lines.txt');input.on('data', function(data) { // after closing the stream, this will not // be called again if (gotFirstLine)...

View Article
Browsing latest articles
Browse All 11 View Live




Latest Images