You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2024-09-16] [$250] Account Settings- App freezes after sending a log file #47509
Version Number: v9.0.20-6 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/4859439 Issue reported by: Applause Internal Team
Action Performed:
Go to Account Settings -> Troubleshoot
Enable "Client side logging"
Press "View debug console"
Press "Share log"
Press on any conversation
Expected Result:
The user should be moved to the report and logs should be sent as an attachment.
The app is stable and functional to return to the previous screen or access the user's profile.
Actual Result:
The user is moved to the report and logs are sent as an attachment.
The back button and the user's profile function become unresponsive. The app sometimes crashes after a few minutes.
@strepanier03 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
changed the title [-]mWeb-Account Settings- App freezes after sending a log file[/-][+]Account Settings- App freezes after sending a log file[/+]on Aug 15, 2024
Edited by proposal-police: This proposal was edited at 2023-10-02T10:00:00Z.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Step to reproduce the issue (aside from OP's step)
Open app
Try to send an .txt attachment (One way to obtain it is exporting the onyx client log in Troubleshooting menu)
Observe that the app freeze / crash (sometimes), and in the console infinite errors happen
What is the root cause of that problem?
We are trying to add log to Onyx in here, but the extraData can be non-serializable. One possible way that the extraData is non-serializable is due to this, as in this case, the request contains a File-type field.
The problem is that at first, the file field in AddAttachment API request params is still serializable (doesn't contain arraybuffer/stream data type), hence the request data is somehow persisted in Onyx (both in cache storage and in keyvalue store). However, after the request data is added to the FormData and sent, the file object now contains arrayBuffer and other binary/stream types which is non-serializable, hence making the addLog Onyx operation to fail.
We can explain the non-stop error message log by following: Since the request is thrown in a promise chain without a proper catch, it will bubble up to the
, which again trying to produce another log and added it to Onyx. The problem is, the current Onyx pre-merged value for the OnyxKeys.Log field contains File-type data in the cache, and Onyx is trying to set the merged data (including the File data in the indexedDB storage -> causing it the serializable issue as described in the screenshot above)., and the error will bubble back to the ErrorBoundary -> infinite circle.
Extra note: Theoretically, we also encounter this issue while persisting AddAttachment request in Onyx storage, but it's hardly reproducible, and we see in practice that at first, the File object is still serializable, but then once the request is successfully executed, it will be removed forever, hence, the File object doesn't entail in the Onyx cache, causing further issue for subsequent merge/mergeCollection operations. However, with logging in Onyx, it is File object is still in the cache for a while, hence subsequent merge/mergeCollections will bump into this error.
What changes do you think we should make in order to solve the problem?
We should try to serialize the request.data before adding to the log. A holistic function can be enough. We can add more support for some special data type like File or Blob, or tune the implementation details based on our needs.
// in @libs/Middleware/Logging.tsfunctionserializeValue(value: any): string{constseen=newWeakSet();functionserialize(item: any): any{// Handle primitive typesif(item===undefined||item===null)returnitemif(typeofitem==="number"||typeofitem==="boolean")returnitemif(typeofitem==="string")returnitem// Handle special objectsif(iteminstanceofDate)returnitem;if(iteminstanceofRegExp)returnitem;// Handle arraysif(Array.isArray(item)){if(seen.has(item))return"\"[Circular]\"";seen.add(item);constserializedArray=item.map(serialize);seen.delete(item);returnserializedArray;}// Handle objectsif(typeofitem==="object"){if(seen.has(item))return"\"[Circular]\"";seen.add(item);constentries=Object.fromEntries(Object.entries(item).map(([key,val])=>[key,serialize(val)]));seen.delete(item);returnentries;}// Handle functions and other non-serializable typesconsttype=item.constructor.name||Object.prototype.toString.call(item).slice(8,-1);return`"[Not serializable: ${type}]"`;}returnserialize(value);}functionlogRequestDetails(message: string,request: Request,response?: Response|void){
....constextraData: Record<string,unknown>={};/** * We don't want to log the request and response data for AuthenticatePusher * requests because they contain sensitive information. */if(request.command!=='AuthenticatePusher'){extraData.request={
...request,data: request.data,}extraData.response=response;}Log.info(message,false,logParams,false,extraData);}
What alternative solutions did you explore? (Optional)
changed the title [-]Account Settings- App freezes after sending a log file[/-][+][$250] Account Settings- App freezes after sending a log file[/+]on Aug 19, 2024
[@suneox] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment
[@suneox] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N/A
[@suneox] Determine if we should create a regression test for this bug: N/A: This issue has handled an edge case when updating the log request.
Both contracts paid and closed with feedback left. I was OoO for a bit and this came due during that time, then the Hold status had it hidden from me and I missed it. Thank you for the bumps.
Activity
melvin-bot commentedon Aug 15, 2024
Triggered auto assignment to @strepanier03 (
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 commentedon Aug 15, 2024
We think that this bug might be related to #wave-collect RELEASE 1
IuliiaHerets commentedon Aug 15, 2024
@strepanier03 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
[-]mWeb-Account Settings- App freezes after sending a log file[/-][+]Account Settings- App freezes after sending a log file[/+]dominictb commentedon Aug 19, 2024
Edited by proposal-police: This proposal was edited at 2023-10-02T10:00:00Z.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Step to reproduce the issue (aside from OP's step)
.txtattachment (One way to obtain it is exporting the onyx client log in Troubleshooting menu)What is the root cause of that problem?
We are trying to add log to Onyx in here, but the
extraDatacan be non-serializable. One possible way that theextraData is non-serializableis due to this, as in this case, the request contains aFile-type field.The problem is that at first, the
filefield inAddAttachmentAPI request params is still serializable (doesn't containarraybuffer/streamdata type), hence the request data is somehow persisted in Onyx (both in cache storage and in keyvalue store). However, after the request data is added to the FormData and sent, thefileobject now containsarrayBufferand other binary/stream types which is non-serializable, hence making theaddLogOnyx operation to fail.We can explain the non-stop error message log by following: Since the request is thrown in a promise chain without a proper catch, it will bubble up to the
App/src/components/ErrorBoundary/index.tsx
Line 18 in d7c9087
OnyxKeys.Logfield containsFile-type data in the cache, and Onyx is trying to set the merged data (including theFiledata in the indexedDB storage -> causing it the serializable issue as described in the screenshot above)., and the error will bubble back to theErrorBoundary-> infinite circle.Extra note: Theoretically, we also encounter this issue while persisting
AddAttachmentrequest in Onyx storage, but it's hardly reproducible, and we see in practice that at first, theFileobject is still serializable, but then once the request is successfully executed, it will be removed forever, hence, theFileobject doesn't entail in the Onyx cache, causing further issue for subsequent merge/mergeCollection operations. However, withloggingin Onyx, it isFileobject is still in the cache for a while, hence subsequent merge/mergeCollections will bump into this error.What changes do you think we should make in order to solve the problem?
We should try to
serializetherequest.databefore adding to the log. A holistic function can be enough. We can add more support for some special data type likeFileorBlob, or tune the implementation details based on our needs.What alternative solutions did you explore? (Optional)
[-]Account Settings- App freezes after sending a log file[/-][+][$250] Account Settings- App freezes after sending a log file[/+]melvin-bot commentedon Aug 19, 2024
Job added to Upwork: https://www.upwork.com/jobs/~016f26106fe45b6825
melvin-bot commentedon Aug 19, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @suneox (
External)23 remaining items
suneox commentedon Sep 24, 2024
Bugzero Checklist
suneox commentedon Sep 24, 2024
@strepanier03 The checklist is completed, and we can proceed with the payment.
dominictb commentedon Sep 30, 2024
@puneetlath Since this is awaiting payment. Can you remove the
MonthlyandReviewinglabels and addDaily?trjExpensify commentedon Oct 1, 2024
Done that for you, @dominictb.
melvin-bot commentedon Oct 4, 2024
@puneetlath, @strepanier03, @suneox, @dominictb Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
puneetlath commentedon Oct 6, 2024
@strepanier03 looks like this is awaiting payment from you.
strepanier03 commentedon Oct 7, 2024
Both contracts paid and closed with feedback left. I was OoO for a bit and this came due during that time, then the Hold status had it hidden from me and I missed it. Thank you for the bumps.