Blank website after update

Hi,

I just updated our Discourse Forum and it’s now blank (homepage and admin). The HTML looks OK, RSS are working.

I found JS errors due to our theme. Can the problem come from here?

How can I fix that? Can I modify/disable the JS code of my theme from CLI? Install a new theme?

Edit: I’ve no other theme installed, so i can’t use ?preview_theme_id=

1 Like

Hey @CamilleRoux

You can also change the default theme directly in the DB with SQL, if you are comfortable with direct DB queries.

HTH

1 Like

Did you try How to use Discourse Safe Mode?

2 Likes

What are you doing :thinking: ?

  • Check safe mode: https://forum.humancoders.com/?safe_mode=no_custom%2Cno_plugins%2Conly_official

  • Logs https://forum.humancoders.com/logs (private ?)

Try via SHH run this:

cd /var/discourse
git pull
./launcher rebuild app
3 Likes

The safe mode is not working… same error:

ReferenceError: Discourse is not defined
    at https://forum.humancoders.com/assets/start-discourse-efa4e5abfbd1b50b5152ffbe64d5dcea9f7c33f766dcc6387e2711f0f2112148.js:1:1

I already did a rebuild ./launcher rebuild app

I haven’t other themes installed, so I should install a new theme with CLI or modify the existing one. I don’t know how to do that

OH, so your default theme has broken stuff in it, so there’s no way to disable it? If that’s what happened, then that’s why you want to always put those customizations in theme components (thought this isn’t a helpful time to tell you that!). (But I’m not entirely sure that’s the case).

And you have no 3rd party plugins?

I guess what you need to do, maybe, is at the rails console, create a new empty theme, and then change the default to the new theme. I don’t know, offhand, just how to do that.

3 Likes

I’m not totally sure yet that the problem come from the theme.
But if it’s the case, yes, creating an empty theme and set it by default could solve the problem. I don’t know how to do that :frowning:

Me neither. :man_shrugging:

Me neither. I think I could figure it out, but I’ve got a bunch of paying work that I’m trying not to do on a weekend.

Hi @CamilleRoux

I just checked your site for you by setting the UA string in the dev console to Google bot. This will display the Rails only site without the Ember SPA.

You can see that you site is “OK” from a Rails perspective, so this indicates your container is running fine and, as you have guessed, you have a Javascript issue in your theme (component).

See attached:

@CamilleRoux

Can you get to a psql prompt (or use the rails console if you like) and run these queries:

Let’s check to see how many themes you have installed:

discourse=# select count(*) from themes;
 count 
-------
    22
(1 row)

Let’s check to see what is your default theme id (currently):

discourse=# select value from site_settings where name = 'default_theme_id';
 value 
-------
 3
(1 row)

Also, can you run this as well?

discourse=# select id, name, component, enabled from themes;
 id |           name            | component | enabled 
----+---------------------------+-----------+---------
  3 | Light                     | f         | t
  6 | Minima                    | f         | t
  7 | Hamburger Theme Selector  | t         | t
  2 | Material Dark             | f         | t
  8 | Vincent                   | f         | t
  5 | Material                  | f         | t
  9 | Simple                    | f         | t
 10 | Graceful Wide             | f         | t
 11 | Dark Wide                 | f         | t
 14 | Alien Night               | f         | t
 39 | md-composer-extras-neo    | t         | t
 40 | Plugin Outlets            | t         | f
 15 | User Card Directory       | t         | f
 41 | Raw Post Button           | t         | t
  4 | Graceful                  | f         | t
  1 | Dark for GSE              | f         | t
 42 | Dark                      | f         | t
 43 | discourse gifs            | t         | t
 44 | Cookie Consent Banner     | t         | t
 46 | Graceful Edits            | t         | t
 45 | Neo Stuff Scratch Sheets  | t         | t
 48 | Unformatted Code Detector | t         | t
4 Likes

OBTW,

@CamilleRoux

I just tested this for you.

After you run the queries in my post above to list all your themes (and you have a record of the current state of your themes), assuming you can get to your DB and run this query, either rails or from psql; you can try this:

Query to disable all theme components

discourse=#  update themes set enabled = false where component = true;

This query above will turn off all your theme components.

Then you can see “what happens” when you try to access your broken site.

If I was in your current situation, based on checking your site as a bot UA, I would turn off all theme components.

Actually, I would turn them off one at a time, starting with any theme component related to nav links (see JS error below ,as a starting place); because I am comfortable and experienced with direct SQL DB queries. Do you have strong SQL skills?

If you are not comfortable with this, you can message me and give me access and I will help you get past this “not so good situation” you are in. I am pretty sure, based on the info I have at this time, I can help you get up and running again :slight_smile:

See also your JS error:
Discourse.ExternalNavItem=Discourse.NavItem.extend({href:function(){return this.get('href');}.property('href')});I18n.translations.fr.js.filters.formations={title:"Formations",help:"Formations pour développeur·se·s"};Discourse.NavItem.reopenClass({buildList:function(category,args){var list=this._super(category,args);list.push(Discourse.ExternalNavItem.create({href:'https://www.humancoders.com/',name:'formations'}));return list;}});jQuery(function($){$(document).on("ready",function(){if(Cookies.get('hcFirstPage')==undefined){$(document).on('click','.toggle-menu',function(e){e.preventDefault();$('.main-nav').toggleClass('show');});var tweenBounce=TweenMax.to('#topbar',1.2,{maxHeight:"50px",delay:2,ease:Power1.easeInOut});var tweenBounceBack=TweenMax.to('#topbar',1.2,{maxHeight:"4px",delay:5.5,ease:Power1.easeInOut});Cookies.set('hcFirstPage',true,{expires:.04});}else{var tweenBounce=TweenMax.to('#topbar',0);}
window.addEventListener('unload',function(){Cookies.remove('hcFirstPage');});var tweenOpen,tweenClose;$('.topbar-toggle').on('mouseenter',function(){tweenBounce.kill();tweenOpen=TweenMax.to('#topbar',.4,{maxHeight:"50px",ease:Power1.easeInOut});});$('#topbar-zone-click').on('mouseenter',function(){tweenBounce.kill();tweenOpen=TweenMax.to('#topbar',.4,{maxHeight:"50px",ease:Power1.easeInOut});});$('#topbar').on('mouseenter',function(){tweenBounce.kill();tweenOpen=TweenMax.to('#topbar',.4,{maxHeight:"50px",ease:Power1.easeInOut});});$('#topbar-zone-click').on('mouseleave',function(){tweenOpen.kill();tweenClose=TweenMax.to('#topbar',.4,{maxHeight:"4px",ease:Power1.easeInOut});});$('.topbar-toggle').on('mouseleave',function(){tweenOpen.kill();tweenClose=TweenMax.to('#topbar',.4,{maxHeight:"4px",ease:Power1.easeInOut});});$('#topbar').on('mouseleave',function(){tweenOpen.kill();tweenClose=TweenMax.to('#topbar',.4,{maxHeight:"4px",ease:Power1.easeInOut});});});});
6 Likes

OK thank you falks for your help.
It’s an old install and I had no other theme/component install. So you couldn’t change my theme or disable all the component.
So I restored an old backup, updated my theme, then updated Discourse. It’s better, but I still have one error (out of 2 before).

Here is the error:

Uncaught ReferenceError: Discourse is not defined
<anonymous> /assets/start-discourse-efa4e5abfbd1b50b5152ffbe64d5dcea9f7c33f766dcc6387e2711f0f2112148.js:1

Here is what contains this file:

Discourse.start();

Do I have an old version of the default theme? (the current theme was created in 2016 by just adding some CSS and JS to the default theme)

PS : The website is running again because I’m using the backup without updating Discourse.

4 Likes

Then I think what I’d do is create a new generic theme and make it the default, then do the upgrade and fix up your theme.

4 Likes

Little update: I’ve the bug on some versions of Discourse but not all.
It’s working correctly on stable and tests-passed but not on beta. So I admit the bug has been already fixed but not commited to beta.

2 Likes

But the problem with your theme customization or a default one?

With the current beta, I have the same bug whatever the theme.