我正在使用pngjs来读取和写入一些 PNG。我定期收到此错误:
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)
但它并没有在我的程序中给我一个行号。
我只在几个地方处理流,它们是:
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);
});
和
result.png.pack().pipe(fs.createWriteStream(diffName));
这三个文件名永远不会相同,因此它们不应该读/写到同一个地方。我想有可能一个流没有从以前的失败运行中正确关闭。有没有办法可以强制所有流很好地关闭?