
Thank you to the folks who came (from my Facebook announcement) to test the revived chat feature.
It went well, and surfaced one problem to fix. There is a race condition where your own post can appear to be duplicated in the chat window. These phantom double-posts only show for the sender of the message, and go away if you refresh the page. It was sort of a known issue before, but testing made it obvious that it is a lot more common than previously thought. This will get fixed tomorrow.
If you want more details about the issue, read on.
The chat page polls the server for new messages and shows them as they get posted. But if you're posting your own message, why wait until it gets to the server and back before showing it? It can be shown right away to the user that posted it without the round trip. Let's call this "fast-display" for the sake of this story. When working well, this makes the chat seem a little bit more responsive to the end user. Well, sometimes the newly-posted message makes the full round trip and shows up before this fast-display code even completes. So when the fast-display code does complete, it places a duplicate "phantom" message for the user after the real message that came back from the server. The fix will be to just get rid of this fast-display technique and solely rely on the round-trip for everything. This simplifies the code A LOT actually, and I'm happy to rip it out (including an entire PHP-file/endpoint). With this testing, it's clear the chat will feel just as (or nearly so) responsive even without this "feature".
It went well, and surfaced one problem to fix. There is a race condition where your own post can appear to be duplicated in the chat window. These phantom double-posts only show for the sender of the message, and go away if you refresh the page. It was sort of a known issue before, but testing made it obvious that it is a lot more common than previously thought. This will get fixed tomorrow.
If you want more details about the issue, read on.
The chat page polls the server for new messages and shows them as they get posted. But if you're posting your own message, why wait until it gets to the server and back before showing it? It can be shown right away to the user that posted it without the round trip. Let's call this "fast-display" for the sake of this story. When working well, this makes the chat seem a little bit more responsive to the end user. Well, sometimes the newly-posted message makes the full round trip and shows up before this fast-display code even completes. So when the fast-display code does complete, it places a duplicate "phantom" message for the user after the real message that came back from the server. The fix will be to just get rid of this fast-display technique and solely rely on the round-trip for everything. This simplifies the code A LOT actually, and I'm happy to rip it out (including an entire PHP-file/endpoint). With this testing, it's clear the chat will feel just as (or nearly so) responsive even without this "feature".
Last edited by BenFenner
on 2025-02-06
at 16-37-07.