I'm using pngjs to read and write some PNGs. I'm getting this error periodically:
Error: There are some read requests waiting on finished stream
at ChunkStream._end (/home/mbayazit/qatools/pdiff/node_modules/pngjs/lib/chunkstream.js:107:13)
at ChunkStream.end (/home/mbayazit/qatools/pdiff/node_modules/pngjs/lib/chunkstream.js:94:14)
at PNG.end (/home/mbayazit/qatools/pdiff/node_modules/pngjs/lib/png.js:105:18)
at ReadStream.onend (_stream_readable.js:483:10)
at ReadStream.g (events.js:175:14)
at ReadStream.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:910:16
at process._tickCallback (node.js:415:13)
But it doesn't give me a line-number inside my program.
I only deal with streams in a few places though, they are:
fs.createReadStream(oldScreen).pipe(new PNG).on('parsed', function() {
promises[0].resolve(this);
});
fs.createReadStream(newScreen).pipe(new PNG).on('parsed', function() {
promises[1].resolve(this);
});
And
result.png.pack().pipe(fs.createWriteStream(diffName));
The three filenames are never the same, so they shouldn't be reading/writing to the same place. I suppose it's possible that a stream did not get closed properly from a previous failed run though. Is there a way I can force all the streams to close nicely?
Two suggestions:
Use longjohn
, it may be able to provide with line numbers inside your code. (The exception happens in an async block, so your stack trace does not contain your program, it only stacks with the tick handler in the V8 main loop).
It seems like the problem is that someone is trying to read from a stream that has just "ended" (was closed, or has reached its end and the underlying layer signaled "end").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With