After developing a unique javascript chat system with php on the backend, the following techniques were utilized:
1) Implementing long-polling to retrieve new messages for the receiver
2) Utilizing sessionStorage to maintain the message counter
3) Utilizing setInterval to check for new messages and displaying the latest message if sessionStorageCounter < setIntervalCounter
4) Using javascript for creating, updating, and displaying chat dialogues
While the module functions properly, it seems that during fast-paced chatting sessions, the receiver's front end sometimes receives duplicate messages (counter and query checks out fine).
Despite the correctness of the code (omitted for brevity), the issue could potentially lie in the interval delay, which remains unresolved even after reducing it.
Considering the scenario described above, do you believe the current system architecture is suboptimal? If so, what alternative schema would you propose to rectify these errors?