Problem/Motivation
When we have a page with inbox, a thread of messages being displayed and notifications, these ajax calls are being made from time to time:
- get_new_messages
- get_new_inblox_threads
- get_new_unread_thread_count (or get_new_unread_message_count depending on the configuration)
Now on another tab of the browser, I logout and then I return to the previous tab.
This happens:
- get_new_messages: continues to be called countless times and errors being shown to the user and being logged.
- get_new_inblox_threads: continues to be called countless times and errors being shown to the user and being logged.
- get_new_unread_thread_count (or get_new_unread_message_count depending on the configuration): is called one time and stops.
To have so many errors being generated is a problem, the user will see countless errors and it will overflow the error logs.
Proposed resolution
On the frontside we can change the javascript code to not repeat calls after an error.
On the backend we can provide an event for requests that will check if it is related with Private messages and if there is no session, in that case it redirects to , stopping the repetitive calls.
Issue fork private_message-3502496
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
dxvargas commentedComment #4
dxvargas commentedI'm proposing a minimal change that does the trick. This situation is not common to happen, so I don't think we should put too much code for it.
Actually my proposal seems like what should be there is first place. If there is an error it doesn't make sense to continue the javascript routines.
Comment #5
alorencComment #6
alorencThis has some side effects. If I log in again inside the second tab, the system will no longer update messages in the first tab.
I don't know which option is better
Comment #7
alorencComment #8
dxvargas commentedThanks for the review @alorenc! I've updated the MR with your suggestions.
Yes true, but the user sees error messages, so the fact that the page is not working shouldn't be a surprise.
Maybe the error message could be improved. Not it shows " Oops, something went wrong. Check your browser's developer console for more details.". But I would first fix this problem and then improve the UI if necessary.
Comment #9
alorencLooks fine, Ajax calls do not generate infinite errors.
Comment #12
claudiu.cristeaThank you for report & fix
Comment #13
claudiu.cristeaIncluded in 4.0.0-alpha3