-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs.outputFileSync issue with sharp 33.1 - worked in 32.6 #3935
Comments
It looks like you're writing the output to the input file so you'll need to use sharp.cache(false) to disable libvips' filesystem cache. I guess the latest sharp+libvips is just slightly faster enough that it's started to expose this existing race condition in your code. In addition, the |
awesome, that seems to have worked. Thank you so much! I added sharp.cache(false) like:
|
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation? YES
npm install sharp
completes without error.node -e "require('sharp')"
completes without error.Are you using the latest version of sharp? YES
sharp
as reported bynpm view sharp dist-tags.latest
.What is the output of running
npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp
?System:
OS: Windows 11 10.0.22621
CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Memory: 16.97 GB / 31.95 GB
Binaries:
Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
npm: 10.2.3 - C:\Program Files\nodejs\npm.CMD
npmPackages:
sharp: ^0.33.1 => 0.33.1
What are the steps to reproduce?
I am looping over files in a folder and using fs.outpurFileSync() to resave the files - awaiting a buffer. With the prior version of sharp this works fine (32.6) but on 0.33.1 it results in an error.
What is the expected behaviour?
no error
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
repo here: https://github.com/rdyar/sharp-test
but this is the code, fairly short:
Please provide sample image(s) that help explain this problem
samples in repo, doesn't matter what the images are.
If I wrap that last line - fs.outputFileSync in a settimeout for 100 or more ms it seems to work. There seems to be some sort of issue with awaiting the buffer.
The text was updated successfully, but these errors were encountered: