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.

Command icon 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

dxvargas created an issue. See original summary.

dxvargas’s picture

Assigned: Unassigned » dxvargas
Status: Active » Needs work

dxvargas’s picture

Assigned: dxvargas » Unassigned
Status: Needs work » Needs review

I'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.

alorenc’s picture

Assigned: Unassigned » alorenc
alorenc’s picture

This 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

alorenc’s picture

Assigned: alorenc » Unassigned
Status: Needs review » Needs work
dxvargas’s picture

Status: Needs work » Needs review

Thanks for the review @alorenc! I've updated the MR with your suggestions.

If I log in again inside the second tab, the system will no longer update messages in the first tab.

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.

alorenc’s picture

Status: Needs review » Reviewed & tested by the community

Looks fine, Ajax calls do not generate infinite errors.

claudiu.cristea made their first commit to this issue’s fork.

claudiu.cristea’s picture

Status: Reviewed & tested by the community » Fixed

Thank you for report & fix

claudiu.cristea’s picture

Included in 4.0.0-alpha3

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.