dimo414 / bkt

a subprocess caching utility, available as a command line binary and a Rust library.
https://www.bkt.rs
MIT License
251 stars 13 forks source link

bkt: stdout pipe failed: failed to write whole buffer #44

Closed agostonbarna closed 1 year ago

agostonbarna commented 1 year ago

Hi, I recently ran into an error with bkt:

bkt -- find . -type f | head -n1
./file
bkt: Subprocess execution failed: stdout pipe failed: failed to write whole buffer

This only seem to happen with many files/lines, but I don't get the error when piping the stdout to wc -l, so maybe the issue only happens when the process on the right side of the pipe closes the stdout of the bkt process before it could write out it's whole output (e.g. head, fzf).

bkt -- find . -type f | wc -l
286910

The stdout is actually correct in both cases so it sounds like this bkt error is not really necessary to show to the user.

Reproduced with:

dimo414 commented 1 year ago

Thanks for the report! 0.7.0 was just released so this is likely a regression (i.e. you can workaround via 0.6.1 in the meantime), I'll see if I can reproduce and fix.

For reference, the error message is coming from write_all() which we don't strictly need to call.

dimo414 commented 1 year ago

@agostonbarna would you mind trying out these binaries and confirming the issue is resolved on your end? I'll cut a 0.7.1 as soon as I hear from you.

agostonbarna commented 1 year ago

Hey @dimo414 , Wow, thanks for the quick fix! I checked again with both the previous (0.7.0) and your new bkt version (0.7.1), and I can only reproduce it with the old one, so it looks good 👍

dimo414 commented 1 year ago

Thanks for confirming!