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

[HOLD for payment 2024-04-03] [$500] Web - Thread - Console error ERR_FAILED 404 shows up when opening thread #38174

Closed
1 of 6 tasks
kbecciv opened this issue Mar 12, 2024 · 43 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@kbecciv
Copy link

kbecciv commented Mar 12, 2024

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: 1.4.51-0
Reproducible in staging?: y
Reproducible in production?: n
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com.
  2. Go to any chat.
  3. Send a message.
  4. Right click on the message > Reply in thread.

Expected Result:

No console error will show up.

Actual Result:

Console error ERR_FAILED 404 shows up.

Workaround:

Unknown

Platforms:

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

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

Screenshots/Videos

Add any screenshot/video evidence

Bug6411473_1710273044161.20240313_034855.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01bff0ded70edc9c84
  • Upwork Job ID: 1768311805142413312
  • Last Price Increase: 2024-03-14
  • Automatic offers:
    • Pujan92 | Reviewer | 0
    • tienifr | Contributor | 0
@kbecciv kbecciv added the DeployBlockerCash This issue or pull request should block deployment label Mar 12, 2024
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

Copy link

melvin-bot bot commented Mar 12, 2024

Triggered auto assignment to @luacmartins (Engineering), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

@kbecciv
Copy link
Author

kbecciv commented Mar 12, 2024

We think that this bug might be related to #vip-vsb
CC @quinthar

@luacmartins
Copy link
Contributor

I'm gonna demote this to NAB. Nothing seems broken, we make a 2nd request to AuthenticatePusher that succeed. We reverted this PR that touched this logic around this subscribe logic that might have caused this.

@luacmartins luacmartins added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Mar 12, 2024
Copy link

melvin-bot bot commented Mar 12, 2024

Triggered auto assignment to @dylanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@dylanexpensify
Copy link
Contributor

Reviewing today!

@luacmartins
Copy link
Contributor

Found the issue in the logs. It seems like we're trying to subscribe to the report channel before the report is created, so there's a race condition somewhere.

@luacmartins luacmartins added the External Added to denote the issue can be worked on by a contributor label Mar 14, 2024
@melvin-bot melvin-bot bot changed the title Web - Thread - Console error ERR_FAILED 404 shows up when opening thread [$500] Web - Thread - Console error ERR_FAILED 404 shows up when opening thread Mar 14, 2024
Copy link

melvin-bot bot commented Mar 14, 2024

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

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

melvin-bot bot commented Mar 14, 2024

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

@tienifr
Copy link
Contributor

tienifr commented Mar 14, 2024

Proposal

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

Console error ERR_FAILED 404 shows up.

What is the root cause of that problem?

In here and here, we're not checking that the report is actually the current report in the route. When we navigate to a new page, the report could be outdated/not yet initialized.

Let's say we're on report 111, when we create a new report and navigate to report 222 the reportID is now 222 and the report there are still in pending creation. But the report here is actually still an empty report/or the 111 report because the 222 report wasn't loaded yet. So didCreateReportSuccessfully is true and we do the subscribing on the 222 report, which leads to 404 error because the 222 report wasn't loaded yet.

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

In the above places here and here, check that report.reportID === reportID before subscribing to pusher channel. If they are not equal, that means the report was not yet loaded/report was outdated and we should early return.

if (reportID !== report.reportID) {
    return;
}

Also in here, we should have report.reportID as dependency too.

While investigating, I also found there's another bug where in here, we don't use .current on the ref, so !didSubscribeToReportLeavingEvents will always evaluate to false and we'll always be unsubscribing the LeavingRoomReportChannel even though in some cases we never subscribed to it. To fix it we can just use .current on the ref correctly.

For the report typing subscription here, we never unsubscribes, we might want to add unsubscription logic similar to for the leaving room event here.

What alternative solutions did you explore? (Optional)

NA

@bernhardoj
Copy link
Contributor

Proposal

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

We have authenticate pusher console error when opening a thread.

What is the root cause of that problem?

We try to subscribe to the pusher before the report is created. We currently have 2 subscriptions, one in the report screen and one in the report actions view.

const didCreateReportSuccessfully = !report.pendingFields || (!report.pendingFields.addWorkspaceRoom && !report.pendingFields.createChat);
if (!didSubscribeToReportLeavingEvents.current && didCreateReportSuccessfully) {
Report.subscribeToReportLeavingEvents(reportID);
didSubscribeToReportLeavingEvents.current = true;
}

const didCreateReportSuccessfully = !report.pendingFields || (!report.pendingFields.addWorkspaceRoom && !report.pendingFields.createChat);
if (!didSubscribeToReportTypingEvents.current && didCreateReportSuccessfully) {
Report.subscribeToReportTypingEvents(reportID);
didSubscribeToReportTypingEvents.current = true;
}

The problem is in the report screen. When we open a new thread, it's possible that the report onyx data is not available yet, so the didCreateReportSuccessfully condition will return true because the pending fields are empty.

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

We can add a new check to make sure the report object has a report ID.

const didCreateReportSuccessfully = report.reportID && (!report.pendingFields || (!report.pendingFields.addWorkspaceRoom && !report.pendingFields.createChat));

What alternative solutions did you explore? (Optional)

Move the subscription to the report actions view too because it's only rendered when the report is already loaded.

@tienifr
Copy link
Contributor

tienifr commented Mar 14, 2024

Proposal updated to add example code changes

@Pujan92
Copy link
Contributor

Pujan92 commented Mar 15, 2024

Thanks for the proposals. Both have covered the RCA correctly which seems to be Report onyx data might not be available post navigating to the thread. Regarding the solutions @tienifr I don't think we need to compare the route report id and onyx report id, because if it is still old report then didSubscribeToReportLeavingEvents ref value is enough to identify and avoid subscribing the events. Validating reportID of report onyx data is enough and seems correct to me. With that, we can go with @bernhardoj's proposal.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Mar 15, 2024

Current assignee @luacmartins is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@tienifr
Copy link
Contributor

tienifr commented Mar 15, 2024

Validating reportID of report onyx data is enough

@Pujan92 I believe comparing the reportID is safer and doesn’t cause any regressions right?

In this line, I don't think we'd feel confident saying didCreateReportSuccessfully is true here if the report we check is different from the report from the route.

Do you think just checking reportID exists is substantially different from my proposal, especially when there’s no harm (even safer) if we do the comparison as in my proposal? 😄

cc @luacmartins

@melvin-bot melvin-bot bot removed the Overdue label Mar 18, 2024
@luacmartins
Copy link
Contributor

I agree that we should minimize these changes to avoid other regressions

@bernhardoj
Copy link
Contributor

This case might be rare but still I think it is a valid point.
Instead of breaking some other things I think it is better to validate only reportID here as a safer side.

Oh yes, that's technically possible. I agree to just validate the reportID.

@Pujan92
Copy link
Contributor

Pujan92 commented Mar 19, 2024

@luacmartins Can you plz check the review comment and other followed comments to decide whom to assign? Also, both contributors have provided valuable inputs so we may consider the bounty split if you think the same.

@tienifr
Copy link
Contributor

tienifr commented Mar 19, 2024

@luacmartins TLDR;

@tienifr's proposal is the first one posted, and suggests comparing the reportID of the report with the reportID from the route, and make sure they match before subscribing to the event. @tienifr also suggested to fix 1 additional bug on the event unsubscription, in the same flow.

@bernhardoj's proposal suggests to rely on the existence of report.reportID, if it exists, subscribe to the event. There's also an alternative solution, initially @bernhardoj favored that more but after a potential issue/regression was highlighted, now @bernhardoj favored the main solution.

@Pujan92 also prefers that report.reportID existence check, thinking that comparing the reportID of the report with the reportID from the route is not needed. Meanwhile @tienifr thinks the reportID comparison is stricter and safer, and doesn't have any drawback compared to the reportID existence check (besides, only @tienifr's proposal contains the unsubscription bug fix).

Let us know what you think!

@luacmartins
Copy link
Contributor

I agree that both contributors added value to this issue, so we can split the bounty. As for the proposal, I like @tienifr's solution more since it's stricter.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 19, 2024
Copy link

melvin-bot bot commented Mar 19, 2024

📣 @Pujan92 🎉 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

Copy link

melvin-bot bot commented Mar 19, 2024

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

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@dylanexpensify
Copy link
Contributor

nice!

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Mar 21, 2024
@tienifr
Copy link
Contributor

tienifr commented Mar 21, 2024

PR ready for review #38657.

@dylanexpensify
Copy link
Contributor

Merged, waiting for regression period then paying out!

@tienifr
Copy link
Contributor

tienifr commented Apr 1, 2024

@dylanexpensify PR hit production 5 days ago. Payment due should be on April 03.

@tienifr
Copy link
Contributor

tienifr commented Apr 16, 2024

@dylanexpensify Bump on the above ^. @Pujan92 Please complete the checklist once you have time.

@Pujan92
Copy link
Contributor

Pujan92 commented Apr 23, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

Regression Test Steps

  1. Open report
  2. On any message(which isn't replied before) open context menu and select reply in thread
  3. Verify thread report opens and isn't showing a AuthenticatePusher 404 error in the console

Do you agree 👍 or 👎 ?

@Pujan92
Copy link
Contributor

Pujan92 commented Apr 23, 2024

@dylanexpensify seems automation is broken for this issue.

@luacmartins luacmartins changed the title [$500] Web - Thread - Console error ERR_FAILED 404 shows up when opening thread [HOLD for payment 2024-04-03] [$500] Web - Thread - Console error ERR_FAILED 404 shows up when opening thread Apr 23, 2024
@luacmartins luacmartins added Awaiting Payment Auto-added when associated PR is deployed to production and removed Reviewing Has a PR in review labels Apr 23, 2024
@luacmartins
Copy link
Contributor

Updated the issue. Bump @dylanexpensify for payment

@dylanexpensify
Copy link
Contributor

Paid out!

@dylanexpensify
Copy link
Contributor

done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
No open projects
Archived in project
Development

No branches or pull requests

6 participants