Logs 'Job exception: unexpected return' error

Hello :wave:

I鈥檝e noticed this error in /logs. Which is probably related with this commit: PERF: defer loading channels (#26155) 路 discourse/discourse@bbb8595 路 GitHub


Job exception: unexpected return
/var/www/discourse/plugins/chat/app/services/chat/list_channel_messages.rb:177:in `block in update_user_last_channel'
/var/www/discourse/lib/scheduler/defer.rb:115:in `block in do_work'
rails_multisite-6.0.0/lib/rails_multisite/connection_management/null_instance.rb:49:in `with_connection'
rails_multisite-6.0.0/lib/rails_multisite/connection_management.rb:21:in `with_connection'
/var/www/discourse/lib/scheduler/defer.rb:109:in `do_work'
/var/www/discourse/lib/scheduler/defer.rb:97:in `block (2 levels) in start_thread'

Few other info:

  • The thread function is disabled now on my site.

  • I鈥檝e noticed the error shows up in /logs when I open the chat and it jump to the last visited channel. When I go back to the channel list and close the chat, the error won鈥檛 show up in /logs after open the chat.


  1. Open chat and go to a channel
  2. Close chat
  3. Open chat again which will jump to the last visited channel

The error should appear in /logs.

Edit: Seems it sometimes happens also when I go to a channel from channel list.
Edit 2: It happens when I go to the last visited channel from channel list.

Thanks :slightly_smiling_face:


Good catch @Don thanks. Will be fixed in FIX: do not use return in block by jjaffeux 路 Pull Request #26260 路 discourse/discourse 路 GitHub