-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Need a way to detect end of stream on custom Writable Streams implementing _write #2994
Comments
Actually, I'm surprised this was not already in place. (or is it?) |
Why not call |
I think the |
It's not public. Take a look at this PR: #2314 |
@vkurchatkin ah, thanks for pointing me to that. @GeorgeBailey they might be interested in hearing your use case. |
@brendanashworth, I am piping an ( I realize a more common approach to process isolation is to set up I can certainly see other cases where detecting end of stream would be appropriate. (i.e. an encoding stream that has to add trailing data to the end of a compressed file format) |
@jhamhader, There needs to be a way to distinguish data from end of stream. The easiest way to do this is just overriding the The method you suggest is less efficient as it requires parsing the stream for a pre-determined string. (similar to a mime id) My understanding is that Writable Streams are intended to provide a more robust solution via an override to |
Did anything ever come of this? If not, is anything likely to come of it? (Basically, trying to figure out if this should be closed or if something could happen to get things moving, as it's been dormant for 7 months...) |
Also need this... Use case is to convert http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property to a sync call that returns a write stream (I'm writing an adapter and have to conform to a stream returning interface which I have no control over). // aws-sdk, callback api
s3.upload({ Key: 'somekey', Body: readStream }, (err) => {
// etc.
}) const { PassThrough } = require('stream')
const createWriteStream = (key) => {
const through = new PassThrough()
s3.upload({ Key: key, Body: through }, (err) => {
// etc.
})
return through
} The above doesn't cut it because the |
This is solved by #12828 and the new |
It seems that _write should be called with
null
as the data, when the end of stream is reached.The problem I am having is that I need to add additional data to the end of the stream, and the
finish
event should not be emitted until after that is completed. I need a way to control this, so I'm thinking a new_end
function with a callback, or perhaps a callback on_write(null)
would do the trick.The text was updated successfully, but these errors were encountered: