discourse/plugins/chat
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
..
admin/assets/javascripts DEV: Introduce <DPageHeader /> and <DPageSubheader /> components (#30146) 2024-12-18 08:13:39 +10:00
app DEV: Unify params access in services 2024-12-13 11:13:18 +01:00
assets DEV: Remove unnecessary optional chaining operators (#30400) 2024-12-20 16:48:13 +01:00
config Update translations (#30319) 2024-12-18 15:19:37 +01:00
db DEV: Make sure chat migration is in plugin directory (#29867) 2024-11-20 14:50:15 -07:00
lib FIX: add server-side limit for DM channels (#30300) 2024-12-16 18:36:29 +01:00
public
spec DEV: Introduce <DPageHeader /> and <DPageSubheader /> components (#30146) 2024-12-18 08:13:39 +10:00
test/javascripts DEV: Run prettier correctly for bundled-plugin test directories (#30338) 2024-12-18 12:02:28 +00:00
README.md DEV: Chat service object initial implementation (#19814) 2023-02-13 13:09:57 +01:00
plugin.rb FIX: better handle race condition when a channel is deleted (#30403) 2024-12-21 00:49:21 +01:00

README.md

This plugin is still in active development and may change frequently

Documentation

The Discourse Chat plugin adds chat functionality to your Discourse so it can natively support both long-form and short-form communication needs of your online community.

For user documentation, see Discourse Chat.

For developer documentation, see Discourse Documentation.