I have narrowed down the problem further to this section of code in UserChatController::indexAction()
// We have to check that the thread is owned by the user.
$is_own_thread = isset($_SESSION[SESSION_PREFIX . 'own_threads'])
&& in_array($thread_id, $_SESSION[SESSION_PREFIX . 'own_threads']);
$thread = Thread::load($thread_id, $token);
if (!$thread || !$is_own_thread) {
throw new NotFoundException('The thread is not found.');
}
What happens here is that.
1. The visitor starts the chat but doesn't close/exit the chat.
2. The visitor closes their browser tab but not the browser so the browser session is still active. Or, in my case, puts the computer to sleep for about a day.
3. On the server, the session is expired or garbage collected since there has been no activity for a long time (e.g session.gc_maxlifetime)
4. When the visitor returns, the thread id is not found in the session in the highlighted code above.
5. This causes the Not Found and always loading behavior
To handle this condition, some client side code could be added that if the server returns a Not Found for the thread, then the frame is closed...
If you can find a way to quickly expire the session then you can reproduce this without waiting for a day. I can open a ticket in GitHub if this is confirmed a bug.
Eyong