-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[$500] Web - Unlimited API requests when image endpoint is giving 404 #26904
Comments
Triggered auto assignment to @slafortune ( |
Bug0 Triage Checklist (Main S/O)
|
ProposalPlease re-state the problem that we are trying to solve in this issue.Unlimited API requests when image endpoint is giving 404. What is the root cause of that problem?The root cause is that we don't have error handling. App/src/components/ImageWithSizeCalculation.js Lines 74 to 91 in b119f9a
When the image starts to load ( onLoadStart ), the logic in place checks if isLoading is false . If so, it sets isLoading to true . but during the process of the image fully loading (onLoadEnd ), isLoading is then correctly set back to false .Therefore this makes an infinite rerender. Each time the component re-renders, it triggers onLoadStart again. Since isLoading is now true , it toggles back to false , perpetuating the loop.
We set What changes do you think we should make in order to solve the problem?To resolve this problem, I suggest modifying the condition in if (!isLoadedRef.current) {
return;
}
setIsLoading(false);
setIsImageCached(true); This solution might prevent What alternative solutions did you explore? (Optional)I investigated various options, such as utilizing |
Job added to Upwork: https://www.upwork.com/jobs/~01c7adabaca13f7f62 |
Triggered auto assignment to @greg-schroeder ( |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ntdiary ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.The image component should enter an infinite re-render loop. What is the root cause of that problem?When the image starts loading, it will set When the loading ends, it will set When the The reason why it doesn't happen when the Image is loaded successfully because when that happens, in What changes do you think we should make in order to solve the problem?We can simply use
And use that source here. What alternative solutions did you explore? (Optional)This unnecessary loading of the |
ProposalPlease re-state the problem that we are trying to solve in this issue.Web - Unlimited API requests when image endpoint is giving 404 What is the root cause of that problem?In App/src/components/ImageWithSizeCalculation.js Lines 79 to 88 in 7c9fc84
we set
App/src/components/Image/index.js Lines 33 to 42 in 7c9fc84
What changes do you think we should make in order to solve the problem?We should wrap In App/src/components/Image/index.js Line 33 in 7c9fc84
We should use network.isOffline to allow re-load image when the network is on |
Please re-state the problem that we are trying to solve in this issue.Unlimited API requests when image endpoint is giving 404 What is the root cause of that problem?the issue, is that there might have been a situation where onLoadStart was being triggered multiple times, leading to the re-render loop. What changes do you think we should make in order to solve the problem?Setting
add this in line number 80. Setting Video: https://drive.google.com/file/d/1Oia-tg6VXTaktknQ3vEV687jK189iJE9/view?usp=sharing |
Not sure why you got assigned as well @greg-schroeder, since I'm going on sabbatical I'll just remove myself. |
ProposalPlease re-state the problem that we are trying to solve in this issue.Unlimited API requests when image endpoint is giving a 404. What is the root cause of that problem?In the the What changes do you think we should make in order to solve the problem?Here: const [isImageCached, setIsImageCached] = useState(true);
const [isLoading, setIsLoading] = useState(false); We can change the initial states of in the in the In the
In the Image component, we could check to see if the image is not cached and is currently loading. When image loads completely, we can set the caching value to true and the |
📣 @jNembhard! 📣
|
@Pluto0104 , eh, do we only need to change this one place? It seems not working.
|
Contributor details |
✅ Contributor details stored successfully. Thank you for contributing to Expensify! |
@Pluto0104 , It looks like your updated version will keep showing loading indefinitely, and the image cannot reload even when the device is back online. Pluto0104.mp4 |
@dukenv0307 , your proposal also does not reload the image when the device is online. dukenv0307.mp4@tienifr, your [proposal] seems to add wrapping |
Reviews continue on linked PR |
This issue has not been updated in over 15 days. @dannymcclain, @ntdiary, @cristipaval, @greg-schroeder, @kaushiktd eroding to Monthly issue. P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do! |
Work continues on linked PR - seems like it's been going a while, is there anything you need from Expensify team to help push this over the finish line? |
@greg-schroeder, so far, in my personal opinion, the fallback icon will only be displayed when there is a failure to load the generic receipt image. And I noticed that our code introduced the "EReceipt" concept. If the below document providing a more detailed explanation of it, could you please grant me access to it? I would like to understand this concept for further clarification. |
Hmm. I'm not sure if we can share access to that as it's an internal design doc, I am asking. |
Discussing in Slack |
|
Offer sent to @kaushiktd |
I'll pay that out as soon as you accept. Closing this accordingly! |
That is a bummer! But alright. And I accepted the offer as well. |
One more request, since I have not worked on Upwork for quite a long time, can you please give me nice rating with review? This will mean a lot to me. |
Yes of course - I left a 5 star review. I'll get it on my list to create the new issue for the other item. @ntdiary indicated we weren't in a great place for that yet so we want to split it out to get a more unified approach going |
So can I submit solution of second part here OR will you create a new issue? |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
Expected Result:
The image component should not enter an infinite re-render loop.
Actual Result:
The image component should enter an infinite re-render loop.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.3.65.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:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
bug-report.mp4
Recording.4304.mp4
Expensify/Expensify Issue URL:
Issue reported by: @napster125
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1694029320303739
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: