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:
parent
4bb1e0d113
commit
1404a169ca
1 changed files with 23 additions and 0 deletions
|
@ -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,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue