Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.56k stars 2.9k forks source link

[$250] Messages are not showing in the LHN when someone sends it #45356

Closed m-natarajan closed 3 months ago

m-natarajan commented 4 months ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: Reproducible in staging?: needs reproduction Reproducible in production?: needs reprroduction If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: @cead22
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1720045541007929

Action Performed:

  1. Have NewDot open as user A
  2. Send a message from user B to user A

    Expected Result:

    UserB's message should update in the LHN

    Actual Result:

    Message does not appear in the LHN and user A has to switch to another chat and open the chat report from B to appear the message

    Workaround:

    unknown

    Platforms:

    Which of our officially supported platforms is this issue occurring on?

    • [ ] Android: Native
    • [ ] Android: mWeb Chrome
    • [ ] iOS: Native
    • [ ] iOS: mWeb Safari
    • [x] MacOS: Chrome / Safari
    • [ ] MacOS: Desktop

Screenshots/Videos

SS before chat :

When opening chat with B image (20)

After opening the chat image (21)

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01263f65273fb956e2
  • Upwork Job ID: 1812617761124974581
  • Last Price Increase: 2024-07-14
  • Automatic offers:
    • dukenv0307 | Reviewer | 103235910
Issue OwnerCurrent Issue Owner: @lakchote
MelvinBot commented 4 months ago

This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989

melvin-bot[bot] commented 4 months ago

Triggered auto assignment to @jliexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

kabeer95 commented 4 months ago

Problem Statement: Messages are not displaying in the LHN (Left Hand Navigation) when someone sends a message, resulting in users missing important notifications and updates.

Root Cause: The root cause of the problem is likely due to an issue with the message rendering logic, WebSocket connection, or data storage.

Changes to Solve the Problem: To solve the problem, I propose the following changes:

  1. Update Message Rendering Logic Update the message rendering logic to ensure that new messages are correctly displayed in the LHN. This includes reviewing the message filtering and sorting logic to ensure that all messages are being displayed correctly.

// Update message rendering logic const MessageList = () => { const messages = useSelector((state) => state.messages); const dispatch = useDispatch();

useEffect(() => { dispatch(fetchMessages()); // Fetch messages on component mount }, [dispatch]);

return (

{messages.map((message) => ( ))}

); };

  1. Verify WebSocket Connection Verify that the WebSocket connection is established correctly and messages are being received from the server. This includes reviewing the WebSocket connection logic and error handling to ensure that messages are not being lost or dropped.

// Verify WebSocket connection const socket = new WebSocket('wss://example.com/ws');

socket.onmessage = (event) => { console.log(Received message: ${event.data}); // Handle incoming message and update LHN };

socket.onopen = () => { console.log('WebSocket connection established'); };

socket.onerror = (event) => { console.error('WebSocket error:', event); };

  1. Check Data Storage Check that messages are being stored correctly in the database and retrieved correctly by the application. This includes reviewing the database schema and query logic to ensure that messages are being stored and retrieved correctly.

-- Check message storage in database SELECT * FROM messages WHERE recipient_id = [user_id]; Alternative Solutions Explored:

Use a Different Message Rendering Library: Explore alternative message rendering libraries, such as react-chat-elements, to see if they provide better performance and reliability. Implement Message Queueing: Implement message queueing to ensure that messages are processed and displayed in the correct order, even in cases of high traffic or network latency. Add Error Handling: Add error handling to the message rendering logic to catch and display any errors that may occur, providing a better user experience.

jliexpensify commented 4 months ago

I can reproduce this with only one person in my LHN - @SofiedeVreese. All of her messages don't appear unless I click out of her chat and back in.

I think this will be hard to accurately repro, but it can be reproduced.

melvin-bot[bot] commented 4 months ago

Job added to Upwork: https://www.upwork.com/jobs/~01263f65273fb956e2

melvin-bot[bot] commented 4 months ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @dukenv0307 (External)

MonilBhavsar commented 4 months ago

I think this should be criticial in newDot quality since it affects core chat workflow cc @muttmuure

jliexpensify commented 4 months ago

Should we make this Internal or keep as External?

melvin-bot[bot] commented 4 months ago

Triggered auto assignment to @lakchote (AutoAssignerNewDotQuality)

cead22 commented 4 months ago

I got some messages from @iwiznia today, and the LHN isn't showing the chat as unread. I looked at onyx and it doesn't look like the report actions are in there, which explains why the message isn't being marked as unread. I think the issue we're seeing in this case is that the messages aren't being delivered to the client

This from gmail

image

And these are the last 3 report actions in onyx for that reportID

[
  {
    "html": "I used our social channel, but maybe I can use a better one, like a public channel",
    "text": "I used our social channel, but maybe I can use a better one, like a public channel",
    "type": "COMMENT",
    "whisperedTo": []
  }
]
[
  {
    "html": "Do you know one with many many participants?",
    "text": "Do you know one with many many participants?",
    "type": "COMMENT",
    "whisperedTo": []
  }
]
[
  {
    "html": "Yeah I think it runs a lot which is why I think 10-12ms <em>could</em> be a problem",
    "text": "Yeah I think it runs a lot which is why I think 10-12ms could be a problem",
    "type": "COMMENT",
    "whisperedTo": []
  }
]

After opening the chat, I get all the messages

[
  {
    "type": "COMMENT",
    "html": "Yeah I think it runs a lot which is why I think 10-12ms <em>could</em> be a problem",
    "text": "Yeah I think it runs a lot which is why I think 10-12ms could be a problem",
    "isEdited": false,
    "whisperedTo": [],
    "isDeletedParentAction": false,
    "deleted": "",
    "reactions": []
  }
]
[
  {
    "type": "COMMENT",
    "html": "And more importantly it runs on many writes.",
    "text": "And more importantly it runs on many writes.",
    "isEdited": false,
    "whisperedTo": [],
    "isDeletedParentAction": false,
    "deleted": "",
    "reactions": []
  }
]
[
  {
    "type": "COMMENT",
    "html": "So 5x on 2ms to 10ms is probably fine, but if there's indeed some that take 50ms and those are also  x 10 that would be 500ms which might be bad",
    "text": "So 5x on 2ms to 10ms is probably fine, but if there's indeed some that take 50ms and those are also  x 10 that would be 500ms which might be bad",
    "isEdited": true,
    "whisperedTo": [],
    "isDeletedParentAction": false,
    "deleted": "",
    "reactions": []
  }
]
[
  {
    "type": "COMMENT",
    "html": "<blockquote>Do you know one with many many participants?</blockquote>No, but yes, probably some of the public channels",
    "text": "Do you know one with many many participants?\nNo, but yes, probably some of the public channels",
    "isEdited": false,
    "whisperedTo": [],
    "isDeletedParentAction": false,
    "deleted": "",
    "reactions": []
  }
]
[
  {
    "type": "COMMENT",
    "html": "Once you find it, you should add it to the PR template: <a href=\"https://github.com/Expensify/Auth/blob/main/.github/PULL_REQUEST_TEMPLATE.md?plain=1#L21\" target=\"_blank\" rel=\"noreferrer noopener\">https://github.com/Expensify/Auth/blob/main/.github/PULL_REQUEST_TEMPLATE.md?plain=1#L21</a>",
    "text": "Once you find it, you should add it to the PR template: https://github.com/Expensify/Auth/blob/main/.github/PULL_REQUEST_TEMPLATE.md?plain=1#L21",
    "isEdited": false,
    "whisperedTo": [],
    "isDeletedParentAction": false,
    "deleted": "",
    "reactions": []
  }
]
[
  {
    "type": "COMMENT",
    "html": "Maybe one of those will do? I assumed big chats mean lots of messages though, not lots of people.",
    "text": "Maybe one of those will do? I assumed big chats mean lots of messages though, not lots of people.",
    "isEdited": false,
    "whisperedTo": [],
    "isDeletedParentAction": false,
    "deleted": "",
    "reactions": []
  }
]
[
  {
    "type": "COMMENT",
    "html": "Yep, just checked, those are chats with only 2 people",
    "text": "Yep, just checked, those are chats with only 2 people",
    "isEdited": false,
    "whisperedTo": [],
    "isDeletedParentAction": false,
    "deleted": "",
    "reactions": []
  }
]
iwiznia commented 4 months ago

Investigated this with @cead22. Here are logs from his device. One of the messages I sent and he was not seeing has actionID of 5285273928576337160

Conclusions are:

My guess is that the bug is that client needs to be updated here but something in OnyxUpdates.saveUpdateInformation is going wrong and the update is never applied.

iwiznia commented 4 months ago

The PR I sent will log whenever we detect the onyx updates need updating.

mallenexpensify commented 4 months ago

Shit.. we have two issues for this! I was able to reproduce this week and shared onyx data with Puneet. Check this thread

Since you sent a PR Ioni, I should close the other one, right? it's here

mallenexpensify commented 3 months ago

I just has an instance where LHN and the chats in #social didn't update. I had a sneaking suspicion they weren't so I captured onyx data, refreshed, then saw new chats load. Hope it's helpful (or you're able to find the logs and those are helpful) social not loading updating.txt

mallenexpensify commented 3 months ago

social still isn't auto-updating for me to show the latest chats in LHN. ie. Vit's showed as being the most recent in LHN but I felt like it had been sent quite a while ago, when I clicked on the channel, it updated to show multiple chats since the one Vit sent.

image

Onyx data before clicking on the room. social not updating onyx.txt

Onyx data after clicking on the chat and opening the room. Social onyx data AFTER chat updated.txt

Let me know if there's anything I can do to help get this fixed.

puneetlath commented 3 months ago

We're discussing the latest theory here: https://expensify.slack.com/archives/C05LX9D6E07/p1721679415535579?thread_ts=1721217121.843389&cid=C05LX9D6E07

Kureev commented 3 months ago

Hi, I am Alexey from Margelo and I can work on this issue.

melvin-bot[bot] commented 3 months ago

📣 @dukenv0307 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job

mallenexpensify commented 3 months ago

lonnnnng thread in #newdot-quality here We encountered the bug this week but the last ~24 hours we haven't been able to reproduce, so we're pausing. #expensify-open-source post asking if others are experiencing.

melvin-bot[bot] commented 3 months ago

@puneetlath @Kureev @jliexpensify @dukenv0307 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

mallenexpensify commented 3 months ago

I think.. hope.. we're all fixed here. Read the [POST MORTEM] Staging jobs not processing email for more deets. Thanks Ioni, Franc and Flo (what a trio of names!)

mallenexpensify commented 3 months ago

Shit... on the latest desktop staging build and chats didn't load after restarting my computer and opening NewDot (I think I updated the app this morn too).

What I see in Desktop now

image

What I see when I open new.expensify.com in Firefox

image

Gonna share in the thread too

mallenexpensify commented 3 months ago

Gonna close this cuz the initial bug here appears to be "I'm active in NewDot and new chats are showing in LHN" where my issue is "After having my laptop closed for some time, I opened Desktop and chats aren't sending (which is likely a reconnect issue)". More discussion here and a new thread for my specific bug here