How I debugged and fixed issues with unread/new counts


(Sam Saffron) #1

Today I fixed a couple of issues with incorrect new and unread counts.

The fixes themselves though interesting are less interesting than the debugging method I used to track it down.

This is how I diagnosed the issues

Run multiple browser windows and catch one misbehaving

Once I isolated a bad actor :dagger:

Open chrome dev tools and run:

Discourse.__container__.lookup('topic-tracking-state:main')

Then walk through the states array:

Using this information I was able to discover that

  1. When a topic was deleted we were not notifying the topic tracking state about this happening

  2. When we were reporting “unread” “latest” etc we were not informing topic tracking state if the topic at hand was a PM, causing PMs to corrupt the counts

There may be more edge cases here, but that is the general gist of how I debug it.

MessageBus is working like a champion and never dropping messages or corrupting ordering.


(Rafael dos Santos Silva) #2

Sam, when a user A creates a topic and stays on it.
User B comes and moves the new topic to another category.
Should the topic refresh the category automatically? It isn’t happening.


(Sam Saffron) #3

Yeah this should refresh category on category edit.


(Rafael dos Santos Silva) #4

Most of my users create the topic on the wrong category, so I edit then all day. Sometimes they need a ninja edit and since the topic is still on the wrong category because the change hasn’t been received, when they edit the text the topic goes back to the original category.

Which I edit again, and we have now 4 revisions.


(Sam Saffron) #5

Sure, open a bug report on it (but search first cause one may exist)