From 317d18ef8c9cf4fd13647518e3fd352774a86481 Mon Sep 17 00:00:00 2001 From: "Nikola R. Hristov" Date: Wed, 3 Apr 2024 13:11:58 +0300 Subject: [PATCH] Disable `sharp` `libvips` cache. (#10616) * Disable `sharp` `libvips` cache. * Update sharp.ts * Add changeset * Apply suggestions from code review * Add issue to comment in sharp.ts --------- Co-authored-by: Emanuele Stoppa --- .changeset/thin-seahorses-whisper.md | 7 +++++++ packages/astro/src/assets/services/sharp.ts | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/thin-seahorses-whisper.md diff --git a/.changeset/thin-seahorses-whisper.md b/.changeset/thin-seahorses-whisper.md new file mode 100644 index 000000000000..c11b11ecdd76 --- /dev/null +++ b/.changeset/thin-seahorses-whisper.md @@ -0,0 +1,7 @@ +--- +"astro": patch +--- + +This change disables the `sharp` `libvips` image cache as it errors when the +file is too small and operations are happening too fast (runs into a race +condition) diff --git a/packages/astro/src/assets/services/sharp.ts b/packages/astro/src/assets/services/sharp.ts index 59a461c6eba7..2493c530175a 100644 --- a/packages/astro/src/assets/services/sharp.ts +++ b/packages/astro/src/assets/services/sharp.ts @@ -32,6 +32,9 @@ async function loadSharp() { throw new AstroError(AstroErrorData.MissingSharp); } + // Disable the `sharp` `libvips` cache as it errors when the file is too small and operations are happening too fast (runs into a race condition) https://github.com/lovell/sharp/issues/3935#issuecomment-1881866341 + sharpImport.cache(false); + return sharpImport; }