"Zlib::BufError: buffer error" - Discourse update fails

AI-generated summary

Users are experiencing a Zlib::BufError: buffer error during Discourse updates, specifically while precompiling assets. The error appears intermittently and is often tied to the MaxMind GeoIP integration. DeanMarkTaylor identified that specifying DISCOURSE_MAXMIND_LICENSE_KEY without DISCOURSE_MAXMIND_ACCOUNT_ID in the .yml config may trigger the failure, and adding the account ID resolved it for several users AquaL1te, JammyDodger, and Roi. However, Jagster and Gunnar report the issue persists even with the account ID set, suggesting a deeper backend issue—possibly a MaxMind service change or deployment inconsistency. mcdanlj notes the error was inconsistent before, hinting at transient backend behavior. Commenting out MaxMind-related lines in app.yml reliably avoids the error, indicating MaxMind is the root trigger, though the exact cause remains unclear. The issue is not plugin-specific, as AquaL1te confirmed it occurs even without unofficial plugins. Rebuilding after adding DISCOURSE_MAXMIND_ACCOUNT_ID is the most common workaround, though not universally effective.

Plugin name is 'discourse-education-group-custom-fields', but plugin directory is named 'discourse-group-custom-fields' 
Purging temp files                                     
Bundling assets                                           
I, [2024-06-10T06:41:22.964825 #1211]  INFO -- : Writing /var/www/discourse/public/assets/break_string-cc617154cd957804f2f6a1f3bc68258c9cdca3d4b9a322bf777d145fed04790e.js
I, [2024-06-10T06:41:22.986328 #1211]  INFO -- : Writing /var/www/discourse/public/assets/service-worker-5ed284060464db53e2bfcd15aca57982a183382ef3e0c86921be9a2ac5ecc196.js
I, [2024-06-10T06:41:22.993446 #1211]  INFO -- : Writing /var/www/discourse/public/assets/locales/i18n-3b40e842fd72b9bcc74ea83e094c823cd9ca535e4ecc5e78722e6f99d3656137.js
I, [2024-06-10T06:41:22.997323 #1211]  INFO -- : Writing /var/www/discourse/public/assets/scripts/discourse-test-listen-boot-9b14a0fc65c689577e6a428dcfd680205516fe211700a71c7adb5cbcf4df2cc5.js
rake aborted!                                                                                                          
Zlib::BufError: buffer error (Zlib::BufError)                                                                          
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sprockets-3.7.3/lib/sprockets/cache/file_store.rb:100:in `<<'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sprockets-3.7.3/lib/sprockets/cache/file_store.rb:100:in `set'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sprockets-3.7.3/lib/sprockets/cache.rb:212:in `set'

...

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'SKIP_EMBER_CLI_COMPILE=1 bundle exec rake themes:update assets:precompile' failed with return #<Process::Status: pid 1209 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "tag"=>"precompile", "hook"=>"assets_precompile", "cmd"=>["su discourse -c 'SKIP_EMBER_CLI_COMPILE=1 bundle exec rake themes:update assets:precompile'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.

There have been a couple of reports of a similar error recently:

Cannot build on arm, Zlib::BufError during assets:precompile
Rebuild fails when these plugins are present

Not sure if an exact cause has been found, but one was thought to be Animated Avatars and the other Subscriptions (though Subscriptions has been rebuilding fine for me).

I don’t use those plugins:

   2   │ discourse_plugins:
   3   │   - https://github.com/discourse/docker_manager
   4   │   - https://github.com/discourse/discourse-rss-polling
   5   │   - https://github.com/discourse/discourse-chat-integration
   6   │   - https://github.com/discourse/discourse-yearly-review
   7   │   - https://github.com/discourse/discourse-perspective-api
   8   │   - https://github.com/discourse/discourse-policy
   9   │   - https://github.com/discourse/discourse-shared-edits
  10   │   - https://github.com/discourse/discourse-akismet
  11   │   - https://github.com/discourse/discourse-solved
  12   │   - https://github.com/discourse/discourse-user-notes
  13   │   - https://github.com/discourse/discourse-templates
  14   │   - https://github.com/discourse/discourse-assign
  15   │   - https://github.com/discourse/discourse-docs
  16   │   - https://github.com/discourse/discourse-encrypt
  17   │   - https://github.com/discourse/discourse-cakeday
  18   │   - https://github.com/discourse/discourse-calendar
  19 _ │   - https://github.com/discourse/discourse-data-explorer
  20   │   - https://github.com/kees-closed/discourse-group-custom-fields
  21   │   - https://github.com/discourse/discourse-activity-pub

I do use MaxMind, so maybe that might be the issue. I also commented out the non-Discourse plugin. That didn’t solve the issue, so I don’t think it is due to a non-official plugin.

I also rebooted the container host, no effect on the build outcome. In the past a networking issue was resolved by a reboot.

Did you try rebuilding without it?

My best explanation for this right now is some spurious error with Maxmind. But looking again at some of the errors that doesn’t make sense either.

I’ve just had this issue when updating a Discourse install…

I believe the cause is because when DISCOURSE_MAXMIND_LICENSE_KEY is specified in the .yml container file without a corresponding DISCOURSE_MAXMIND_ACCOUNT_ID.

@tgxworld’s pull request adds the use of DISCOURSE_MAXMIND_ACCOUNT_ID in multiple places and explains the need for “Account ID”:
https://github.com/discourse/discourse_docker/pull/796

For me the fix was adding DISCOURSE_MAXMIND_ACCOUNT_ID and rebuilding (I rebuilt twice, but this was most likely a temporary issue).

A recent rebuild worked fine. If it fails again I’ll have a look at @DeanMarkTaylor his suggestion. Thanks everyone!

FWIW I just hit the Zlib::BufError: buffer error (Zlib::BufError) rebuild error and adding in the DISCOURSE_MAXMIND_ACCOUNT_ID and rebuilding went through first time for me. :+1:

Same here. Adding the account ID and rebuilding is working again. :slight_smile:

When the 3.3.0.beta3 version was released, I got this error inconsistently; it failed once, and then the rebuild succeeded. (Not having found this post, I worried about memory corruption! :grimacing:) Tonight, doing a rebuild, it consistently failed until I found this post and added DISCOURSE_MAXMIND_ACCOUNT_ID to the existing DISCOURSE_MAXMIND_LICENSE_KEY and then it reliably succeeded.

(I assume something like that maxmind rolled out a change with a blue/green deployment and that earlier I hit different versions of a back end service each time…)

Rebuilding just failed because of MaxMind lines. It worked until now, and without any changes in app.yml it failed now. So something bigger is broken.

What ever, I don’t need it under Discourse, so I let it be commented. But it is totally sure the issue is something else than just account_id.

Agreed. My rebuild failed even with DISCOURSE_MAXMIND_ACCOUNT_ID set in app.yml.

As soon as I commented out all mention of Maxmind, the rebuild succeeded.