A chat channel doesn’t show nor save messages

I upgraded few hours ago, and now all channels that have custom group shows empty channel. I can write and send messages, but if I logout or refresh pages channel has no history.

Logs show this:

Message

NoMethodError (undefined method `replies_count' for nil:NilClass)
(eval):17:in `_fast_attributes'
app/controllers/application_controller.rb:545:in `render_json_dump'
app/controllers/application_controller.rb:532:in `render_serialized'
app/controllers/application_controller.rb:414:in `block in with_resolved_locale'
app/controllers/application_controller.rb:414:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:74:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:369:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
lib/middleware/request_tracker.rb:228:in `call'

Backtrace

plugins/chat/app/serializers/chat/message_serializer.rb:161:in `thread_reply_count'
(eval):17:in `_fast_attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:468:in `rescue in attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:455:in `attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:480:in `_serializable_hash'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:359:in `serializable_hash'
active_model_serializers (0.8.4) lib/active_model/array_serializer.rb:89:in `block in _serializable_array'
active_model_serializers (0.8.4) lib/active_model/array_serializer.rb:79:in `map'
active_model_serializers (0.8.4) lib/active_model/array_serializer.rb:79:in `_serializable_array'
active_model_serializers (0.8.4) lib/active_model/array_serializer.rb:73:in `serializable_array'

Env

HTTP HOSTS: foorumi.katiska.eu

Ideas?

Edit:

If that means something those channels behaving badly were earlier sub-categories, but I changed those to top categories.

But my users are claiming things were broken before that change.

Hi,

did you at any point in time tried to use experimental (and hidden) thread settings?

I’ve changed something long time ago, but… can’t remember what but I’m quite perhaps very sure it has been something that later wasn’t experimental any more.

Do you have something in mind?

It’s still experimental and hidden today, and I mean you have the right to play with this :slight_smile: I’m just trying to scope down the list of possible issues.

The error clearly shows we are trying to access code which shouldn’t be accessed if a thread has never been created, so it’s surprising.

If and when I’ve changed only things I’ve found here, and search didn’t show anything relevant.

Can rails show what isn’t on defaults anymore?

I will merge this in the next 30 minutes, that will fix your issue. We will investigate this more next week but I don’t want you to be blocked on this the whole weekend.

4 Likes

Great!

I would still like to understand what the heck I broke… I’m quite sure I’ve changed earlier only (at that time) new settings of search improvements and similar ones.

But if I’m totally honest… I’ve tendency try something if it can make topics kind of better or something, and if nothing happends I’ll forget it right away.

(And I’m nagging all the about lazy documentation :man_facepalming: )

I don’t have a better answer for now, but we will investigate this next week, I just merged it. Im going offline, let me know if it doesn’t fix it, will look tomorrow.

2 Likes

First: your fix didn’t help. Sorry. Or it did — that error was a little bit strange,

Please, try to follow me :wink:

I have 5 channels:

  • three for TL1
  • one for staff
  • one for custom group of 5 persons

I moved all others than staff-channel from sub-categories to top.

Then I tried how category preview component works, but it wasn’t what I needed, so I disabled it. Right after that I did rebuilding to get category lockdown plugin.

It worked, except I had some weird issues with FKB Pro theme and login/signup-modals — those gave only spinning loading icon. That happened only with my iPad AFAIK.

At that point I realize the chat channel of custom group didn’t work any more. Plus staff-group and 2 of 3 TL1-groups showed only very recent messages. One TL1-group was intact.

I tried safe-mode and disabling most of plugins via settings. No help and I opened this topic.

Long story short and after several rebuildings removing and re-enabling plugins:

  • staff-channel and two TL1-channels are low traffic ones and I forgot totally I’m using 14 days rule there; so there wasn’t any issues
  • custom-group-channel was broken if I had both plugins Data Explorer and Category Lockdown installed, and enabling/disabling didn’t matter
  • rebuilding without those two plugins fixed that one broken channel. When I re-rebuilding (is that a word?) with both plugins that channel was still ok

My un-educated guess is something went sideways when I first tried Category Previews, then I disabled it, then rebuilding with Category Lockdown and the last move was deleting Category Previews. Fixing some bizarre SQL-errors or false bites needed totally removal of Data Explorer and Lockdown, following fresher re-installing.

What I can’t understand is error log of Discourse — how do it fit in all of this.

Anyway. I have all plugins back online and channels work nicely.

Hi @Jagster , I am on the chat team as well and I’m looking into this a bit further. Reading over what you have done, none of that should have caused this error. Each chat message is potentially linked to a chat thread in the database via a thread_id, and one of your messages has a thread_id for a thread that does not exist for…some reason. We don’t have any code to delete threads, so perhaps there was some update that went awry.

Can you try running this query for me and post the results? It will let us see whether you have a widespread issue or if it was just one strange edge case:

SELECT id, chat_channel_id, thread_id
FROM chat_messages
WHERE thread_id IS NOT NULL AND thread_id NOT IN (
  SELECT id FROM chat_threads
);

I used Data Explorer and this I got (I trust you can read json :wink: )

{"success":true,"errors":[],"duration":0.5,"result_count":2,"params":{},"columns":["id","chat_channel_id","thread_id"],"default_limit":1000,"rows":[[10721,14,152],[10744,14,152]]}

The problematic channel was id 14.

1 Like

Thanks for this, I guess we follow a “wait-and-see” approach for this bug, since:

  1. It’s not obvious how it was caused and
  2. It has not been reproduced in a few sites I checked
  3. It’s only happened in one place on your site

One more check would be to just run this query too:

SELECT * FROM chat_threads WHERE id = 152;

And make sure it doesn’t return anything.

Confirmed; zero, nothing

Sure. It is really hard to fix when one can’t find anything.

Thanks guys!

1 Like