bustle / bluestream

A collection of streams that work well with promises (through, map, reduce). Think Through2 with promises
MIT License
103 stars 5 forks source link

stream.push() after EOF #42

Open xloem opened 4 years ago

xloem commented 4 years ago

I'm having some errors thrown sometimes when a stream is stopped prematurely.

const bluestream = require('bluestream')
const pump = require('pump')

test()
async function test()
{
  let count = 0
  let pipeline = pump(
    bluestream.read(() => {
      console.log(`Sending count: ${++count}`)
      return count
    }),
    bluestream.tap(console.log),
  )
  let data = await bluestream.readAsync(pipeline, 3)
  console.log(`Data: ${data}`)
  pipeline.destroy()
  await bluestream.wait(pipeline)
}
(node:13071) UnhandledPromiseRejectionWarning: Error: stream.push() after EOF
    at readableAddChunk (_stream_readable.js:240:30)
    at TapStream.Readable.push (_stream_readable.js:208:10)
    at TapStream.Transform.push (_stream_transform.js:147:32)
    at Promise.resolve.then.value (/home/karl/src/care/projects/bitfiles/node_modules/bluestream/dist/transform.js:92:47)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)