2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-08-17 18:04:11 +08:00

FIX: Zlib may raise BufError during asset:precompile (#31398)

According to Zlib documentation, this is not a fatal error. In this case
we attempt to deflate the asset three times before giving up.

Sprockets will be replaced in the long term and this is an acceptable fix.
This commit is contained in:
Bianca Nenciu 2025-03-07 09:08:06 +02:00 committed by GitHub
parent 4bb1e0d113
commit 1404a169ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,3 +60,26 @@ Sprockets::Asset.prepend(
end
end,
)
# 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,
)