Urgent.News

What's breaking now, across thousands of outlets.

Tech

Unread badges that would not clear: 59 of my 64 messages were junk

I am building a small chat feature for an HR system. Shared hosting, PHP, no WebSocket, polling every few seconds. Nothing exotic. Then a bug report landed. This is what I actually wrote, translated from Korean: "If I open room A, it gets read. So if I close it and open another room, it should stay read. But that doesn't happen — the badge on the room I already opened is still there." The…

A chat feature for an HR system was built using shared hosting and PHP, with no websockets or advanced features. The developer encountered a bug where unread badges in chat rooms did not clear properly, leading to 59 out of 64 messages appearing as unread even when nobody was in those rooms. The issue arose because the chat engine generated system messages each time a user entered or left a room, which were not supposed to be stored.

This led to an incorrect unread count, causing the database to store unnecessary rows. The developer initially suspected encoding problems or stale high-water marks, but after counting the rows, they discovered that 59 of the messages were not written by humans. To fix the issue, the developer overrode a method in the third-party library to exclude system rows from being written and stored.

This resolved the problem, reducing the number of unread messages to zero and removing unnecessary rows from the messages table.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Tuesday 25 August →