question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: file data stream has unexpected number of bytes

See original GitHub issue

Hi!

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:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
thejoshwolfecommented, Apr 12, 2017

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?

0reactions
thejoshwolfecommented, Sep 4, 2018

that’s a relief to hear.

(no need to delete any comments.)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found