Question about ReadableStream<Uint8Array> #606
-
|
Using 2.8.3. // return ReadableStream<Uint8Array>
const stream = adb.sync().read(file.path);
const transform = new TransformStream<Uint8Array, Uint8Array>({
transform(chunk, controller) {
console.log(file.relativePath, chunk);
controller.enqueue(chunk);
},
});
const transformedStream = stream.pipeThrough(transform);
await zipWriter.add(file.relativePath, transformedStream);I added a TransformStream to print debug logs and found that the Uint8Array data view for each file contains the correct range of data. And their underlying buffers actually include the adb sync protocol headers and footers. For example, this 'Hello World' text file:
This seems to cause zip.js to compress the wrong data when using the buffer during compression. There are some strange points: First, I need to compress multiple zip files along with some text files. After zip.js compresses multiple files from adb sync, I tested extracting them and found that only the data from the txt files is abnormal after decompression. For the extracted txt files, only the leading 'DATAxxx' is included; the end is correctly truncated without 'DONE'. Also, this error occurs intermittently—sometimes it works fine, and other times the files have incorrect data at the beginning. It’s possible that all the data being compressed contains adb protocol headers and footers, but during extraction some files appear normal while others are corrupted? I don’t really understand how zip compression works in this regard. Is this a bug? So, aside from manually copying a Uint8Array that doesn’t share the underlying buffer (which seems to work), is there a better solution? Thanks. If you don’t have any ideas or thoughts, I can take the time to try creating a reproduction. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
|
I need to do some investigation I think. Out of curiosity, does it work ok if you replace |
Beta Was this translation helpful? Give feedback.
-
|
Thank you, I was able to reproduce and fix the issue. The fix is available in the version |
Beta Was this translation helpful? Give feedback.

Thank you, I was able to reproduce and fix the issue. The fix is available in the version
2.8.6I've just released.