@ -67,16 +67,19 @@ module.exports = function simpleSinkStream(_options) {
}).catch(isEndOfStream,(error)=>{
}).catch(isEndOfStream,(error)=>{
/* Don't attempt to do another read, we're done. */
/* Don't attempt to do another read, we're done. */
returnPromise.try(()=>{
returnPromise.try(()=>{
if(!onEndCalled&&onEnd!=null){
// Note: we *always* push a value to the buffer when handling the end of the stream - that is intentional. This is necessary because the end can only ever be reached as the ultimate result of a read call on this stream, and that call is expected to return a value. If we only pushed a value to the buffer when there's an onEnd handler producing one, then it would be possible in some cases for the buffer to remain empty, causing an entirely valid read call to result in a thrown EndOfStream error. That error should only be thrown if something *continues* to try and read from it, not at the first moment that the end is reached.