-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 #23143] Dev: Web - App crashes when deleting an image while the image is opened #23896
Comments
Triggered auto assignment to @puneetlath ( |
Bug0 Triage Checklist (Main S/O)
|
ProposalPlease re-state the problem that we are trying to solve in this issue.The problem is that when an image attachment is deleted by User A while it's opened in the view of User B, the app crashes. This is not the expected behavior. The image preview carousel should close when the image gets deleted. What is the root cause of that problem?The root cause of the problem is that when an attachment is deleted, it becomes a null value. Any subsequent attempts to access its properties such as source or URL results in an error, causing the app to crash. What changes do you think we should make in order to solve the problem?A solution is to check if the attachment exists before trying to display it or accessing its properties. This can be achieved by, for example, adding optional chaining (the question mark syntax) to the attachment variable when accessing its properties. Similarly, for
This will ensure that even if the attachment is null, accessing its properties won't cause the application to crash and the modal will close gracefully. We can also manually call Edit 1: Please see comment 2023-07-31.14-11-06.mp4 |
ProposalPlease re-state the problem that we are trying to solve in this issue.Dev: Web - App crashes when deleting an image while the image is opened What is the root cause of that problem?In App/src/components/AttachmentCarousel/index.js Lines 51 to 56 in 024d210
We're executing createInitialState function whenever the reportActions get changed. So when users delete the image, we call => attachments[page] is undefined App/src/components/AttachmentCarousel/createInitialState.js Lines 52 to 58 in 024d210
At this line, we're trying to access data from undefined => App crashes App/src/components/AttachmentModal.js Line 117 in 024d210
What changes do you think we should make in order to solve the problem?We shouldn't call call onNavigate if page is -1 Change App/src/components/AttachmentCarousel/createInitialState.js Lines 53 to 55 in 024d210
to
|
ProposalEven though I've already suggested that we should dismiss the modal if the attachment is not present, I would like to further argue that the functionality of App/src/components/AttachmentCarousel/createInitialState.js Lines 14 to 64 in 8cdb506
A more suitable location would be within the App/src/components/AttachmentCarousel/index.js Lines 51 to 56 in 8cdb506
We can modify this to:
This approach brings several benefits:
|
Thanks @ahmedGaber93. I'm going to go ahead and close this issue out then. Appreciate the help in triaging. |
@puneetlath this issue is a regression of #21334, and is only found on staging and not reproducible on production. The fixing PR @ahmedGaber93 shared is two weeks old pr which is created before this bug was introduced, I am not sure how that pr can fix this issue unless it is amended to do so. I think it is a good idea to keep this issue open and see if a resolution for this issue comes from the offending PR as this comment suggests #22261 (comment) |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
Cool, I'll leave it open and on hold and we can see if that PR fixes it. |
Thanks for the quick reply, Puneet. The issue is fixed and deployed to staging now. Here is the fixing PR #23988 |
Ok so this issue should just be closed out then, is that right? |
Yes, we can close this👍 |
Cool, thanks! |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Action Performed:
Expected Result:
Image preview carousel should close
Actual Result:
App crashes
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: Dev 1.3.47-2
Reproducible in staging?: no
Reproducible in production?: no
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
Screencast.from.2023-07-29.13-46-11.mp4
Expensify/Expensify Issue URL:
Issue reported by: @Natnael-Guchima
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1690627861170639
View all open jobs on GitHub
The text was updated successfully, but these errors were encountered: