gulpjs / vinyl-fs

Vinyl adapter for the file system.
MIT License
970 stars 157 forks source link

Vinyl-fs src corrupts image files #351

Open vkorytska opened 5 months ago

vkorytska commented 5 months ago

While the issue is reproduced for Gulp.src, not for Vinyl.src, but this is relevant because Gulp.src uses Vinyl.src.

What were you expecting to happen?

The task should copy images without issue.

What actually happened?

The task corrupted the images. Similar corruption does not occur for text-based files. '{ removeBOM: false, buffer: false, encoding: false }' arguments do not fix the issue.

Please give us a sample of your gulpfile

I created a (public) repository to show the issue with src and images: https://github.com/vkorytska/gulp-src-issue.

Terminal output / screenshots

Added examples of corrupted images to the repository.

Please provide the following information:

Additional information

This issue is probably similar to https://github.com/aws/aws-sdk-js/issues/1628. In the repository added a quick fix of replacing fs.createReadStream with fs.readFile and the images were copied properly.

I am not sure why specifically image files are corrupted by createReadStream, and not text files.

tommyZZM commented 3 months ago

👍🏽 yes same issue occur to me

pavelhoral commented 3 months ago

I was able to recreate the issue when gulp.src had the same options as in the original post ({ removeBOM: false, buffer: false, encoding: false }). However the issue can not be reproduced with the following options { encoding: false }.

Having removeBOM does not make sense for encoding: false. But the issue is present when buffer: false (so some sort of bug is present there).

UPDATE: I already see the PR that addresses this... so there is no need for additional analysis.