A platform for community discussion. Free, open, simple.
FIX: Zlib may raise BufError during asset:precompile (#31398)
Bianca Nenciu1404a169cafb
diff --git a/lib/freedom_patches/sprockets_patches.rb b/lib/freedom_patches/sprockets_patches.rbindex 928d714bf25..5ab3035e0a3 100644--- a/lib/freedom_patches/sprockets_patches.rb+++ b/lib/freedom_patches/sprockets_patches.rb@@ -60,3 +60,26 @@ Sprockets::Asset.prepend(endend,)++# Sprockets::Cache::FileStore raises `Zlib::BufError: buffer error` sometimes.+# According to zlib documentation, Z_BUF_ERROR is not fatal and can be retried.+# https://www.zlib.net/zlib_faq.html#faq05+Sprockets::Cache::FileStore.prepend(+ Module.new do+ def set(key, value)+ attempts = 3++ begin+ attempts -= 1+ super+ rescue Zlib::BufError+ if attempts > 0+ puts "Zlib::BufError while deflating #{key}, retrying #{attempts} more times"+ retry+ else+ raise+ end+ end+ end+ end,+)