Error: file data stream has unexpected number of bytes
See original GitHub issueHi!
For some reason, I occasionally get the following error when trying to create a zip file. I’d be really grateful if you were able to provide any insight.
Uncaught Exception:
Error: file data stream has unexpected number of bytes
at ByteCounter.<anonymous> (/Applications/Castbridge.app/Contents/Resources/app.asar/node_modules/yazl/index.js:144:99)
at emitNone (events.js:91:20)
at ByteCounter.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Help to resolve: Error in FileYXDBStreaming:: :Rea...
I am faced with the following error: "Error in FileYXDBStreaming:: :Read - Unexpected number of bytes" when Alteryx tries to process the .yxdb ......
Read more >Strange Sudden Error "The number of bytes to be written is ...
I've checked the storage container, and the stream does indeed get uploaded correctly, and I can see the image and all fine, but...
Read more >TPT15140 Error: Invalid number of bytes written to the LOB ...
TPT15140 Error: Invalid number of bytes written to the LOB data file '%s' for column '%s' row: %llu. Wrote %llu bytes to the...
Read more >Troubleshoot throughput error in Amazon Kinesis Data Streams
The ReadProvisionedThroughputExceeded error occurs when GetRecords calls are throttled by Kinesis Data Streams over a duration of time.
Read more >Nodejs使用archiver-zip-encrypted库加密压缩文件时报错
Error : file data stream has unexpected number of bytes at ByteCounter. ( xxx\node_modules\yazl\index.js:162:99)
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My best guess is that the file you’re trying to add to the archive is being modified while yazl is attempting to read it. The specific error means that the fs.ReadStream that’s reading the file produced a different number of bytes than the fs.stat() call predicted it would. (Either that or there’s a serious bug in yazl.)
If I had to guess, I would say that you’re writing files to the file system from some source and then immediately zipping them up into an archive. There’s a really easy mistake to make with Node.js programming where you don’t wait for a WriteStream to fully finish writing its data before you try to read the file. For example, if you wait for a stream earlier in the pipeline to end instead, then you’ll get intermittent failures like the one you’re getting.
That’s all a really specific guess though. Your situation may be different. Can you verify that the files you’re sending to addFile() are not changing while yazl is reading them?
that’s a relief to hear.
(no need to delete any comments.)