Closed mapo-job closed 4 years ago
@sfriesel any idea?
I'm not at home right now but it could happen when end() is called without a precious call to write()? Maybe an empty input stream.
@mapo-job
Is it possible that you try to decompress an empty stream?
By the way I look at the code and not sure where the stream and this.queue is coming. For sure there is no local variable called stream.
Oh, there is, It's the argument to decompressAndQueue
https://github.com/regular/unbzip2-stream/blob/master/index.js#L44
@regular I do not read an empty stream since the file has 52K and process fine when I restarted the script.
Regarding the missing stream variable, the stream cannot come from the previous function since it belong to the function scope.
To verify you can add this line:
console.log(JSON.stringify(stream, null, 2));
after line 83 and you will get
ReferenceError: stream is not defined
Same thing with the this.queue, it shows undefined.
I made a PR for stream.emit
. this.queue
is defined in the underlying stream object produced by through()
. I don't have a good idea how bitReader could be null
especially for a non-empty archive. I have an unfinished branch that replaces through
with Transform
(https://github.com/sfriesel/unbzip2-stream/commits/transform) that may or may not fix this issue.
Both parts of the issue should be fixed with version 1.4.0.
This occur with unbzip2-stream version 1.3.3 after running few days. For an unknown reason the bitReader is null.
81: while (!broken && hasBytes > bitReader.bytesRead){
Here is the stack trace:By the way I look at the code and not sure where the stream and this.queue is coming. For sure there is no local variable called stream.