Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[$250] Web - Attachment - Onyx and DataCloneError console rrrors when sending an image attachment #50780

Closed
1 of 6 tasks
IuliiaHerets opened this issue Oct 15, 2024 · 65 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Oct 15, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.49-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5084384&group_by=cases:section_id&group_order=asc&group_id=292107
Issue reported by: Applause Internal Team

Action Performed:

  1. Navigate to https://staging.new.expensify.com/
  2. Log in with a new Gmail account
  3. Navigate to FAB - Start chat
  4. Start a 1:1 DM with any account
  5. Send any image attachment to the chat

Expected Result:

There shouldn't be any console errors.

Actual Result:

Onyx and DataCloneError console errors when sending an image attachment to a 1:1 DM.
Expensify.tsx:50 [Onyx] Attempted to set invalid data set in Onyx. Please ensure all data is serializable.

index.js:40 Uncaught (in promise) DataCloneError: Failed to execute 'put' on 'IDBObjectStore': function arrayBuffer() { [native code] } could not be cloned.
at index.js:40:15
at index.js:13:51

Workaround:

Unknown

Platforms:

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

1510.txt

Bug6634941_1728975190721.bandicam_2024-10-15_08-47-55-299.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021846724620826087266
  • Upwork Job ID: 1846724620826087266
  • Last Price Increase: 2024-12-05
Issue OwnerCurrent Issue Owner: @rlinoz
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 15, 2024
Copy link

melvin-bot bot commented Oct 15, 2024

Triggered auto assignment to @RachCHopkins (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.

@IuliiaHerets
Copy link
Author

@RachCHopkins FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@RachCHopkins
Copy link
Contributor

I can't repro this, I don't get any errors at all. I note the steps are very specific - does the account need to be brand new and also need to be gmail @IuliiaHerets ?

@daledah
Copy link
Contributor

daledah commented Oct 16, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Onyx and DataCloneError console errors when sending an image attachment to a 1:1 DM.
Expensify.tsx:50 [Onyx] Attempted to set invalid data set in Onyx. Please ensure all data is serializable.

What is the root cause of that problem?

When sending attachment as first message in a new chat room, a SendAttachment request is called, but response's previousUpdateID doesn't match with request's clientUpdateID, thus trigerring SaveResponseInOnyx middleware logics:

Screenshot 2024-10-16 at 13 47 35 Screenshot 2024-10-16 at 13 49 30

In SaveResponseInOnyx, we save the whole request object when the above case happens:

const responseToApply = {
type: CONST.ONYX_UPDATE_TYPES.HTTPS,
lastUpdateID: Number(response?.lastUpdateID ?? 0),
previousUpdateID: Number(response?.previousUpdateID ?? 0),
request,
response: response ?? {},
};

OnyxUpdates.saveUpdateInformation(responseToApply);

In the case of SendAttachment request, the request contains a File object, which is a non-serializable object, which makes Onyx unable to set request values into OnyxDB.

What changes do you think we should make in order to solve the problem?

  1. We can handle this in BE side to response AddAttachment with previousUpdateID matches with clientUpdateID to prevent SaveResponseInOnyx being called
  2. We can serialize File object by wrapping request around JSON.stringify and JSON.parse:
request: JSON.parse(JSON.stringify(request))

We can limit this logic to apply only on SendAttachment as well

const shouldParseRequest = request.command === WRITE_COMMANDS.ADD_ATTACHMENT
/* ... */
request: shouldParseRequest ? JSON.parse(JSON.stringify(request)) : request

What alternative solutions did you explore? (Optional)

@daledah
Copy link
Contributor

daledah commented Oct 16, 2024

@RachCHopkins From my testings, you can try to reproduce with the following conditions:

  • Start a chat with an existing user, not optimistic user
  • Send image as the first message in the chat

@RachCHopkins
Copy link
Contributor

Strange, no, I can't repro. But I trust you @daledah, if you can, then that's good enough for me!

@RachCHopkins RachCHopkins added the External Added to denote the issue can be worked on by a contributor label Oct 17, 2024
@melvin-bot melvin-bot bot changed the title Web - Attachment - Onyx and DataCloneError console rrrors when sending an image attachment [$250] Web - Attachment - Onyx and DataCloneError console rrrors when sending an image attachment Oct 17, 2024
Copy link

melvin-bot bot commented Oct 17, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 17, 2024
Copy link

melvin-bot bot commented Oct 17, 2024

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

Copy link

melvin-bot bot commented Oct 22, 2024

@Pujan92, @RachCHopkins Eep! 4 days overdue now. Issues have feelings too...

@melvin-bot melvin-bot bot added the Overdue label Oct 22, 2024
@RachCHopkins
Copy link
Contributor

@Pujan92 can you check out the above proposal, please?

Copy link

melvin-bot bot commented Oct 24, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@huult
Copy link
Contributor

huult commented Oct 24, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Onyx and DataCloneError console errors when sending an image attachment

What is the root cause of that problem?

This issue related RCA with issue 49329 and 44114

This issue occurs on the backend because when we call the AddAttachment request, the lastUpdateIDFromClient is less than the previousUpdateID received. As a result, the responseToApply ends up using the wrong function to store the responseToApply, which is OnyxUpdates.saveUpdateInformation(responseToApply). In this case, we expect to use OnyxUpdates.apply(responseToApply); to save the response. Additionally, when we use this function, the responseToApply from AddAttachment needs to be serialized first; otherwise, it will throw an error log in this ticket.

{"lastUpdateIDFromClient":2571094520,"previousUpdateID":2571094574}

What changes do you think we should make in order to solve the problem?

To resolve this issue, we need to make a change on the backend so that the previousUpdateID is less than the lastUpdateIDFromClient in this case, or we should always update ADD_ATTACHMENT to the most current state. Something like this:

//.src/libs/Middleware/SaveResponseInOnyx.ts#L12
const requestsToIgnoreLastUpdateID: string[] = [
    WRITE_COMMANDS.OPEN_APP,
    SIDE_EFFECT_REQUEST_COMMANDS.RECONNECT_APP,
    WRITE_COMMANDS.CLOSE_ACCOUNT,
+    WRITE_COMMANDS.ADD_ATTACHMENT,
    WRITE_COMMANDS.DELETE_MONEY_REQUEST,
    SIDE_EFFECT_REQUEST_COMMANDS.GET_MISSING_ONYX_MESSAGES,
];

Copy link

melvin-bot bot commented Oct 24, 2024

@Pujan92, @RachCHopkins 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

@RachCHopkins
Copy link
Contributor

@Pujan92 how do you feel about these proposals?

@Pujan92
Copy link
Contributor

Pujan92 commented Oct 28, 2024

Reviewing

@melvin-bot melvin-bot bot removed the Overdue label Oct 28, 2024
@Pujan92
Copy link
Contributor

Pujan92 commented Oct 28, 2024

As both proposals stated, I think this needs to be fixed in the BE if possible, to correct the values of previousUpdateID and lastUpdateIDFromClient. So that the correct function OnyxUpdates.apply gets called. Adding an internal engineer for the quick look.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Oct 28, 2024

Triggered auto assignment to @rlinoz, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@rlinoz
Copy link
Contributor

rlinoz commented Oct 28, 2024

Im not very familiar with the updateIDs logic, but I will try to take a look today.

@huult
Copy link
Contributor

huult commented Oct 28, 2024

If the backend doesn't have a solution to update it, I think we can still fix this on the frontend, and we can add it to requestsToIgnoreLastUpdateID because, upon checking, it seems we don't need to wait for any requests to update fields in the add attachment request.

@rlinoz
Copy link
Contributor

rlinoz commented Oct 28, 2024

Im not being able to repro this 🤔

@rlinoz rlinoz added the retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause label Nov 20, 2024
Copy link

melvin-bot bot commented Nov 21, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Nov 25, 2024
@rlinoz
Copy link
Contributor

rlinoz commented Nov 25, 2024

Waiting for proposals.

@rlinoz
Copy link
Contributor

rlinoz commented Nov 28, 2024

Still watiting

@melvin-bot melvin-bot bot removed the Overdue label Nov 28, 2024
Copy link

melvin-bot bot commented Nov 28, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Dec 2, 2024
Copy link

melvin-bot bot commented Dec 2, 2024

@rlinoz, @Pujan92, @RachCHopkins Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@rlinoz
Copy link
Contributor

rlinoz commented Dec 2, 2024

Waiting for proposals and retest

@rlinoz
Copy link
Contributor

rlinoz commented Dec 5, 2024

Waiting for proposals and retest

@melvin-bot melvin-bot bot removed the Overdue label Dec 5, 2024
@rlinoz
Copy link
Contributor

rlinoz commented Dec 5, 2024

Might get fixed here though #53417

Copy link

melvin-bot bot commented Dec 5, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Dec 9, 2024
Copy link

melvin-bot bot commented Dec 9, 2024

@rlinoz, @Pujan92, @RachCHopkins Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@rlinoz
Copy link
Contributor

rlinoz commented Dec 9, 2024

Looking here #53417 (comment) I will go ahead and close this issue on favor of that comment/issue.

Let me know if you think I should reopen this one @kubabutkiewicz

@rlinoz rlinoz closed this as completed Dec 9, 2024
@melvin-bot melvin-bot bot removed the Overdue label Dec 9, 2024
@github-project-automation github-project-automation bot moved this from LOW to Done in [#whatsnext] #quality Dec 9, 2024
@kubabutkiewicz
Copy link
Contributor

Hi, wanted to ask if this is still reproducible? I was trying today and no luck but I see that fix to backend about order of ids from here #51712 (comment) is deployed so maybe its also fixed that issue?

@rlinoz
Copy link
Contributor

rlinoz commented Dec 13, 2024

I was never really able to reproduce this, can you please try @Pujan92?

@Pujan92
Copy link
Contributor

Pujan92 commented Dec 13, 2024

I tried when @rlinoz closed the issue and couldn't reproduce it. so it might be fixed with the backend fix as mentioned by @kubabutkiewicz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause
Projects
Development

No branches or pull requests

8 participants