-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Writable Stream problem with end() callback #6868
Comments
Could you provide e.g. a minimal snippet of code with an example where calling |
The code is rather large. To get a working example would be a bit of work, but basically the code is:
Like I mentioned before, when If I attempt to force the If this is not enough to go on, please let me know. I can attempt to reduce the problem to a testable use case. I am just working off of code inspection, but it seems if |
Ah! The docs for // When closing the stream down
usbAudioWriter.on( 'finish', function() {
// Do the close here...
console.log("End Called");
} ); If there’s something you need to do before the writer stream ends, you should be able to override the default behaviour using wavFile = fs.createReadStream( filename );
usbAudioWriter = getWritableStreamSomehow(); // calls a module that inherits from the Writable to stream over our USB API (The end code calls the Writeable.end as is.
wavFile.pipe( usbAudioWriter, { end: false } );
...
// When closing the stream down
wavFile.on('finish', function() {
// do things...
usbAudioWriter.end( function() {
// Do the close here...
console.log("End Called");
} );
} ); |
In my use case the wav file being played is on a continuous loop, so its However, based on your suggestions I was able to get it working similar to your solution. Thanks so much for the time and help. |
I am working on a similar thing where I need to download a zip into to an already open file(that has a valid file descriptor) and also use this file descriptor later on to unzip the file. If I dont use pipe: false then the filestream |
I am trying to close a writable stream using
end()
with a callback. However, whenend()
callsendWritable()
andstate.finished
is set to false so the callback is set to trigger when thefinish
event triggers. The problem is thestate.finished
flag is only set withinfinishMaybe()
. This routine is only called fromendWritable()
andafterWrite()
. However, onceend()
is called you cannot write more data to the stream to triggerafterWrite()
to makestate.finished = true
. It would seem that theend()
callback only works when thestate.finished
is true.I compared the 5.1.1 version of the code with the current master head within git. There have really been no changes to this area of the code.
My question is, How do I get the
end()
callback to work? Is there a problem in the code? If so, is there a workaround? (so far I don't see one) Thanks for the time and any help.The text was updated successfully, but these errors were encountered: