DISCOURSE_CDN_URL يكسر إعادة البناء/الاستعادة

EDIT: Well, it took me 18 hours, but it seems that defining DISCOURSE_CDN_URL keeps (at least) this site from rebuilding and/or functioning after a restore. I guess the next thing to test is doing a build without DISCOURSE_CDN_URL and then cranking up the container with the ENV var set.

What I knew before

I had this problem yesterday but thought it went away, but it turns out that I restored a month-old database. Restoring the recent database kills the site.

I was able to build the site from scratch, so it’s not a problem with the code or any standard plugins. BUT after I have restored the database, the site is down, and I can’t do a rebuild, even if I delete the database, so I guess the problem is something in a file that gets read when it’s compressing the javascript.

I tried removing all of the background: image-url in onebox.scss, which allowed the site to rebuild, but the display is all screwed up, so those errors are a symptom rather than the cause of the problem.

I get errors like the below in the rails log after restoring the database (and files) or when rebuilding.


I, [2019-12-22T21:21:25.532604 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
NOTE: Inheriting Faraday::Error::ClientError is deprecated; use Faraday::ClientError instead. It will be removed in or after version 1.0
Faraday::Error::ClientError.inherited called from /var/www/discourse/plugins/discourse-github/gems/2.6.5/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:14.
> Seeding dark and light themes
[SassC::FunctionsHandler] undefined method `protocol' for nil:NilClass
rake aborted!
Discourse::ScssError: Error: error in C function image-url: undefined method `protocol' for nil:NilClass
        on line 90 of app/assets/stylesheets/common/base/onebox.scss, in function `image-url`
        from line 90 of app/assets/stylesheets/common/base/onebox.scss, in mixin `onebox-favicon`
        from line 110 of app/assets/stylesheets/common/base/onebox.scss
        from line 34 of app/assets/stylesheets/common.scss
        from line 1 of desktop.scss
>>     background: image-url("favicons/#{$image}.png") no-repeat 0% 50%;

   ----------------^
/var/www/discourse/lib/stylesheet/manager.rb:183:in `rescue in compile'
/var/www/discourse/lib/stylesheet/manager.rb:171:in `compile'
/var/www/discourse/lib/stylesheet/manager.rb:80:in `block (2 levels) in stylesheet_details'
/var/www/discourse/lib/stylesheet/manager.rb:66:in `each'
/var/www/discourse/lib/stylesheet/manager.rb:66:in `block in stylesheet_details'
/var/www/discourse/lib/stylesheet/manager.rb:64:in `synchronize'
/var/www/discourse/lib/stylesheet/manager.rb:64:in `stylesheet_details'
/var/www/discourse/lib/stylesheet/manager.rb:34:in `stylesheet_data'
/var/www/discourse/app/models/theme.rb:280:in `block in refresh_message_for_targets'
/var/www/discourse/app/models/theme.rb:279:in `map'
/var/www/discourse/app/models/theme.rb:279:in `refresh_message_for_targets'
/var/www/discourse/app/models/theme.rb:267:in `notify_theme_change'
/var/www/discourse/app/models/theme.rb:275:in `notify_theme_change'
/var/www/discourse/app/models/theme.rb:61:in `block in <class:Theme>'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:429:in `instance_exec'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:429:in `block in make_lambda'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:239:in `block in halting_and_conditional'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.r

@pfaffman لقد صادفت هذه المشكلة بالضبط للتو بعد أن عانيت من مشاكلي الأخرى أثناء محاولة إعداد S3. هل عرفت ما الذي تسبب في ذلك؟

تم إصلاحه. تأكد من إضافة http:// قبل عنوان URL الخاص بشبكة CDN الخاصة بك :facepalm:

لذلك، بدلاً من DISCOURSE_CDN_URL=your-cdn-url.com، يجب أن يكون DISCOURSE_CDN_URL=http://your-cdn-url.com.

فقط ساعتان ضاعتا في تصحيح الخطأ :smiley:

هل يمكننا إضافة نوع من التنبيه هنا @eviltrout حتى لا يواجه الناس هذا في المستقبل؟

سيظهر تحذير إذا لم تقم بإضافة بروتوكول:

لكن الأشخاص غير الأكفاء (مثل أنا) الذين يفعلون ذلك باستخدام متغيرات البيئة سيواجهون مشاكل لا يزال. هل هناك عيب في طباعة التحذير و إضافة https:// في البداية؟

كائن GlobalSetting هو المسؤول عن نقل متغيرات ENV الخاصة بك إلى Discourse، لذا إذا قمت بذلك بهذه الطريقة، فستظهر التحذيرات أيضًا.

أنا أيضًا أشعر بالغباء إلى حد كبير لأنني وقعت في هذه الفخ! :laughing:

إذا كنت أتذكر بشكل صحيح، فقد فقدت 18 ساعة منها خلال ما كان من المفترض أن يكون عطلة عيد الميلاد. :وجه متجهم: