discourse/plugins
Régis Hanol ebb6f1c2d2
FIX: better handle race condition when a channel is deleted (#30403)
NOTE: I wasn't able to reproduce locally, so that's my best guess as to what happens based on the production error logs.
It's also the reason why I haven't changed/added any tests...

Earlier today, we started seeing a growing number of errors in the `register_presence_channel_prefix("chat-reply")` handler of the chat plugin.
It was all coming from a Discourse where they make a heavy use of chat channels. They create and **delete** category channels regularly.

If a user has a thread in one of the channels that just got deleted, the client application might not be aware (just yet), asks the server to be connected to the "presence" bus of that channel, and BOOOM.

The following [line](fa0ad0306c/plugins/chat/plugin.rb (L325)) explodes because `chat_channel` is `nil`

```ruby
config.allowed_group_ids = chat_channel.allowed_group_ids
```

And why is `chat_channel` `nil`? Because when we [do](fa0ad0306c/plugins/chat/plugin.rb (L319))

```ruby
chat_channel = Chat::Thread.find_by!(id: thread_id, channel_id: channel_id).channel
```

The thread is still in the database, but the associated channel has been deleted.

A proper fix would most likely be to delete all the `Chat::Thread` associated to a deleted `Chat::Channel` but this might have more technical & business implications.
2024-12-21 00:49:21 +01:00
..
automation UX: Apply admin table to Automation settings page (#30341) 2024-12-19 05:07:14 -07:00
chat FIX: better handle race condition when a channel is deleted (#30403) 2024-12-21 00:49:21 +01:00
checklist DEV: Consolidate i18n import paths (#29804) 2024-11-19 20:45:18 +00:00
discourse-details DEV: Use qunit-dom's `hasValue` wherever possible (#30018) 2024-12-01 20:37:24 +01:00
discourse-lazy-videos Update translations (#28577) 2024-08-29 15:37:52 -04:00
discourse-local-dates DEV: Run prettier correctly for bundled-plugin test directories (#30338) 2024-12-18 12:02:28 +00:00
discourse-narrative-bot Update translations (#30319) 2024-12-18 15:19:37 +01:00
discourse-presence UX: fix border around reply indicator (#30343) 2024-12-18 12:34:39 -05:00
footnote Update translations (#30062) 2024-12-04 11:59:28 +01:00
poll Update translations (#30319) 2024-12-18 15:19:37 +01:00
spoiler-alert DEV: Use qunit-dom's `hasValue` wherever possible (#30018) 2024-12-01 20:37:24 +01:00
styleguide DEV: Introduce new 'glimmer topic list mode' site setting (#30375) 2024-12-19 17:38:35 +00:00