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
[Due for payment 2026-06-24] [$250] Compose box - Offline attachment disappears after app relaunch before sync #89553
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Navigate to a chat and upload an attachment (image).
Verify that the image preview appears immediately in the chat.
Close/force-kill the app while still offline.
Reopen the app and then enable internet connection (refresh if needed).
Expected Result:
The attachment should remain visible in the chat after reopening the app offline, and once the device goes online it should sync and appear normally (without reduced opacity).
Actual Result:
The attachment uploaded while offline disappears after closing and reopening the app. It does not sync or appear once the internet connection is restored.
When a user picks an attachment in a chat while offline, the native AttachmentPicker copies the file to cachesDirectory — a temporary directory that Android can purge at any time (especially on force-kill). The API write request containing this file reference is queued in PersistedRequests and persisted to Onyx.
After the app is force-killed:
The cache file is deleted by the OS.
On relaunch, the SequentialQueue replays the persisted request.
prepareRequestPayload tries to read the file from the now-invalid URI — since the chat attachment FileObject typically lacks a source property, it falls through to appending the raw (stale) value to FormData, causing a silent upload failure.
Receipt/expense uploads don't have this bug because they call moveReceiptToDurableStorage to move the file to DownloadDir/Receipts-Upload (a durable directory) before queuing — but chat attachments never do this.
Additionally, if the request is already being processed when force-killed, shouldPersistOngoingRequest skips persisting it entirely because it contains a File/Blob object, so the request is lost completely.
What changes do you think we should make in order to solve the problem?
Before the chat attachment upload request is queued in the SequentialQueue, move the file from cachesDirectory to durable storage using moveReceiptToDurableStorage (or a similar mechanism). This should happen in the attachment upload flow in addActions (or the caller that prepares the file), so the file URI in the persisted request points to a location that survives app restarts. The source property should also be set on the FileObject so prepareRequestPayload can re-read it correctly on replay.
What alternative solutions did you explore? (Optional)
Use the existing cacheAttachment display cache (Documents/attachments) as a fallback source for upload. This was rejected because the display cache serves a different purpose and mixing concerns would be fragile.
Detect and clean up stale persisted requests on startup. This would prevent silent failures but wouldn't actually fix the lost-attachment problem — the file would still be gone.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
The optimistic attachment is destroyed by a chain of three independent issues that all converge on Android force-kill:
cacheAttachment is fire-and-forget at src/libs/actions/Report/index.ts:707. The native implementation (src/libs/actions/Attachment/index.native.ts:12-32) does an async RNFS.copyFile(uri, destPath) to the long-lived ${RNFS.DocumentDirectoryPath}/attachments/{attachmentID}.{ext} and only THEN writes COLLECTION.ATTACHMENT{attachmentID} to Onyx. Because addActions does not await it, a force-kill within the few hundred milliseconds before the copy finishes leaves no cached file and no Onyx record.
The optimistic HTML embeds the volatile picker URI directly.getUploadingAttachmentHtml at src/libs/ReportUtils.ts:6308-6320 writes <img src="${file.uri}" ...> and data-expensify-source="${file.uri}" straight from the picker. On Android the picker returns a transient content://... URI scoped to the picker process; once the app is killed the URI is revoked, so on relaunch the persisted optimistic action in REPORT_ACTIONS references a source the OS no longer resolves — the image renders as broken/empty even though the action row exists.
The persisted ADD_ATTACHMENT request loses its file across the kill.PersistedRequests.save() (src/libs/actions/PersistedRequests.ts:225) calls Onyx.set(PERSISTED_REQUESTS, requests) for the queued request whose data.file is a non-serializable RN file blob. The same module already acknowledges this exact serialization problem at lines 376-381 — but ONLY for ongoingRequest; the comment "These requests cannot survive a crash anyway since File references are lost on restart" is never enforced for the queued (non-ongoing) case. After restart, data.file is hydrated as {} (or as an object whose uri points at a revoked content:// URI). When the network returns and SequentialQueue.flush() processes the request, the multipart upload goes out without a usable file: depending on server tolerance the server either fails the request (failureData decorates the action with an error but does not remove it) or accepts a comment-only payload and successData strips pendingAction/isOptimisticAction, leaving a message with no image — i.e. the attachment is "gone" once online.
What changes do you think we should make in order to solve the problem?
Two minimal, narrowly scoped edits, both in src/libs/actions/Report/index.ts inside addActions (the file-attachment branch at lines 701-708):
Await the cache copy before building anything that depends on the URI. Make addActions (or just its file branch) async/await the cacheAttachment call at line 707. This both (a) guarantees the durable file at ${RNFS.DocumentDirectoryPath}/attachments/{attachmentID}.{ext} exists before the optimistic action is committed to Onyx, and (b) gives us a stable path to use in the next step.
Rewrite the URI used by the optimistic action and the persisted request to the cached path. After cacheAttachment resolves, read the freshly written COLLECTION.ATTACHMENT{attachmentID} source (or compute the same destPath locally — ${RNFS.DocumentDirectoryPath}/attachments/{attachmentID}.{ext}) and:
Pass {...file, uri: cachedPath} to buildOptimisticAddCommentReportAction at line 705 so getUploadingAttachmentHtml embeds the long-lived path instead of the volatile picker URI. The <img src="file:///data/.../attachments/{id}.jpg"> stays valid across restarts.
Pass the same rewritten file (with uri: cachedPath) into parameters.file at line 791 so that when the request is persisted by PersistedRequests.save and later replayed by the queue after restart, the multipart upload reads from a real, app-private file rather than from a revoked content URI or a serialized {} object.
Web parity check (no change needed): the web cacheAttachment (src/libs/actions/Attachment/index.ts:10) is not affected because web uses object URLs that survive only inside the same JS runtime; force-kill = full reload there too, but the issue is reproduced only on Android per the report. No edit to the web file is needed.
This keeps the change confined to one function, reuses the existing cacheAttachment infrastructure already in place, and does not require any change to the persisted-request schema or to PersistedRequests.ts.
What alternative solutions did you explore?
Extending the hasNonSerializableData guard (PersistedRequests.ts:376) to save() so non-serializable requests are dropped before persistence: rejected. That would silently delete the queued ADD_ATTACHMENT request on disk, making the failure even more invisible — the queue would have no record to retry, the optimistic action would hang forever in pendingAction=ADD, and the user would see an undismissable ghost message instead of "the image disappeared."
Re-uploading from the optimistic ReportAction's HTML on restart by parsing the data-expensify-source attribute and re-fetching: rejected. The picker content:// URI is already revoked at this point; the only durable copy is the one we should have written via cacheAttachment in the first place. Fixing the source of truth (await the copy, rewrite the URI) is strictly less work and has no schema impact.
Making the entire addActions function synchronous and skipping the cache for offline: rejected. The cache is exactly what makes the offline preview possible — skipping it would regress the "image preview appears immediately" expectation in step 4 of the repro.
changed the title [-]Compose box - Offline attachment disappears after app relaunch before sync[/-][+][$250] Compose box - Offline attachment disappears after app relaunch before sync[/+]on May 4, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-05-04 18:44:03 UTC.
Proposal
What is the root cause of that problem?
On Android, chat attachments are created in a temporary cache path (cachesDirectory) by the picker flow.
When the app is force-killed while still offline, that temporary file may not survive process restart.
Two things then break together:
The optimistic report action still references the old temporary URI, so the attachment preview disappears after relaunch.
The queued offline upload can also replay with a stale file reference (or missing source path), so the request cannot reliably rebuild multipart payload when network returns.
So this is a file-lifecycle mismatch: we queue offline work using a non-durable file location.
What changes do you think we should make in order to solve the problem?
Use a durability-first upload path for chat attachments (native only), and keep display cache separate.
Normalize attachment before queuing request
In the chat attachment send flow, if file is local/offline, move it from temp cache to a durable app-owned upload staging path.
If move succeeds, set:
file.uri = durableUri (for optimistic rendering),
file.source = durableUri (for offline replay in prepareRequestPayload).
If move fails, keep current URI as fallback and log a warning.
Use normalized file everywhere in the same flow
Build optimistic attachment HTML from normalized file (uri now durable).
Send API write payload with normalized file (source present for replay).
Keep responsibilities separated
upload staging = reliability for request replay (all MIME types).
cacheAttachment = rendering/cache optimization only (do not depend on it for upload durability).
Add cleanup lifecycle
Remove staged upload file after terminal outcome (success or non-retriable failure), to avoid stale file growth.
Same scenario with a non-image file (e.g., PDF) to verify MIME-agnostic durability.
Multi-attachment path (first with text + remaining attachments) to ensure all files follow same normalization.
What alternative solutions did you explore? (Optional)
Rely only on existing cacheAttachment
Rejected: it is display-oriented and file-type constrained, so it is not a reliable upload source for all attachment types.
Drop/clean persisted requests on startup when file is invalid
Rejected: prevents silent retries but loses user data and does not solve root durability issue.
Patch optimistic preview only
Rejected: UI may look fixed, but upload replay can still fail without durable source.
Reuse receipt-specific durable logic directly
Partially viable, but rejected as-is: receipt path has different lifecycle assumptions. Better to apply the same durability principle via a chat-attachment staging path with clear cleanup ownership.
⚠️@neerajbachani Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
⚠️@oqildev Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
MelvinBot commentedon May 4, 2026
Proposal
What is the root cause of that problem?
When a user picks an attachment in a chat while offline, the native
AttachmentPickercopies the file tocachesDirectory— a temporary directory that Android can purge at any time (especially on force-kill). The API write request containing this file reference is queued inPersistedRequestsand persisted to Onyx.After the app is force-killed:
prepareRequestPayloadtries to read the file from the now-invalid URI — since the chat attachmentFileObjecttypically lacks asourceproperty, it falls through to appending the raw (stale) value to FormData, causing a silent upload failure.Receipt/expense uploads don't have this bug because they call
moveReceiptToDurableStorageto move the file toDownloadDir/Receipts-Upload(a durable directory) before queuing — but chat attachments never do this.Additionally, if the request is already being processed when force-killed,
shouldPersistOngoingRequestskips persisting it entirely because it contains a File/Blob object, so the request is lost completely.What changes do you think we should make in order to solve the problem?
Before the chat attachment upload request is queued in the SequentialQueue, move the file from
cachesDirectoryto durable storage usingmoveReceiptToDurableStorage(or a similar mechanism). This should happen in the attachment upload flow inaddActions(or the caller that prepares the file), so the file URI in the persisted request points to a location that survives app restarts. Thesourceproperty should also be set on the FileObject soprepareRequestPayloadcan re-read it correctly on replay.What alternative solutions did you explore? (Optional)
cacheAttachmentdisplay cache (Documents/attachments) as a fallback source for upload. This was rejected because the display cache serves a different purpose and mixing concerns would be fragile.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.melvin-bot commentedon May 4, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ZhenjaHorbach (
External)Abdulloh0109 commentedon May 4, 2026
Proposal
What is the root cause of that problem?
The optimistic attachment is destroyed by a chain of three independent issues that all converge on Android force-kill:
cacheAttachmentis fire-and-forget atsrc/libs/actions/Report/index.ts:707. The native implementation (src/libs/actions/Attachment/index.native.ts:12-32) does an asyncRNFS.copyFile(uri, destPath)to the long-lived${RNFS.DocumentDirectoryPath}/attachments/{attachmentID}.{ext}and only THEN writesCOLLECTION.ATTACHMENT{attachmentID}to Onyx. BecauseaddActionsdoes notawaitit, a force-kill within the few hundred milliseconds before the copy finishes leaves no cached file and no Onyx record.The optimistic HTML embeds the volatile picker URI directly.
getUploadingAttachmentHtmlatsrc/libs/ReportUtils.ts:6308-6320writes<img src="${file.uri}" ...>anddata-expensify-source="${file.uri}"straight from the picker. On Android the picker returns a transientcontent://...URI scoped to the picker process; once the app is killed the URI is revoked, so on relaunch the persisted optimistic action inREPORT_ACTIONSreferences a source the OS no longer resolves — the image renders as broken/empty even though the action row exists.The persisted
ADD_ATTACHMENTrequest loses its file across the kill.PersistedRequests.save()(src/libs/actions/PersistedRequests.ts:225) callsOnyx.set(PERSISTED_REQUESTS, requests)for the queued request whosedata.fileis a non-serializable RN file blob. The same module already acknowledges this exact serialization problem at lines 376-381 — but ONLY forongoingRequest; the comment "These requests cannot survive a crash anyway since File references are lost on restart" is never enforced for the queued (non-ongoing) case. After restart,data.fileis hydrated as{}(or as an object whoseuripoints at a revokedcontent://URI). When the network returns andSequentialQueue.flush()processes the request, the multipart upload goes out without a usable file: depending on server tolerance the server either fails the request (failureData decorates the action with an error but does not remove it) or accepts a comment-only payload andsuccessDatastripspendingAction/isOptimisticAction, leaving a message with no image — i.e. the attachment is "gone" once online.What changes do you think we should make in order to solve the problem?
Two minimal, narrowly scoped edits, both in
src/libs/actions/Report/index.tsinsideaddActions(the file-attachment branch at lines 701-708):Await the cache copy before building anything that depends on the URI. Make
addActions(or just its file branch)async/awaitthecacheAttachmentcall at line 707. This both (a) guarantees the durable file at${RNFS.DocumentDirectoryPath}/attachments/{attachmentID}.{ext}exists before the optimistic action is committed to Onyx, and (b) gives us a stable path to use in the next step.Rewrite the URI used by the optimistic action and the persisted request to the cached path. After
cacheAttachmentresolves, read the freshly writtenCOLLECTION.ATTACHMENT{attachmentID}source (or compute the samedestPathlocally —${RNFS.DocumentDirectoryPath}/attachments/{attachmentID}.{ext}) and:{...file, uri: cachedPath}tobuildOptimisticAddCommentReportActionat line 705 sogetUploadingAttachmentHtmlembeds the long-lived path instead of the volatile picker URI. The<img src="file:///data/.../attachments/{id}.jpg">stays valid across restarts.uri: cachedPath) intoparameters.fileat line 791 so that when the request is persisted byPersistedRequests.saveand later replayed by the queue after restart, the multipart upload reads from a real, app-private file rather than from a revoked content URI or a serialized{}object.Web parity check (no change needed): the web
cacheAttachment(src/libs/actions/Attachment/index.ts:10) is not affected because web uses object URLs that survive only inside the same JS runtime; force-kill = full reload there too, but the issue is reproduced only on Android per the report. No edit to the web file is needed.This keeps the change confined to one function, reuses the existing
cacheAttachmentinfrastructure already in place, and does not require any change to the persisted-request schema or toPersistedRequests.ts.What alternative solutions did you explore?
hasNonSerializableDataguard (PersistedRequests.ts:376) tosave()so non-serializable requests are dropped before persistence: rejected. That would silently delete the queuedADD_ATTACHMENTrequest on disk, making the failure even more invisible — the queue would have no record to retry, the optimistic action would hang forever inpendingAction=ADD, and the user would see an undismissable ghost message instead of "the image disappeared."data-expensify-sourceattribute and re-fetching: rejected. The pickercontent://URI is already revoked at this point; the only durable copy is the one we should have written viacacheAttachmentin the first place. Fixing the source of truth (await the copy, rewrite the URI) is strictly less work and has no schema impact.addActionsfunction synchronous and skipping the cache for offline: rejected. The cache is exactly what makes the offline preview possible — skipping it would regress the "image preview appears immediately" expectation in step 4 of the repro.[-]Compose box - Offline attachment disappears after app relaunch before sync[/-][+][$250] Compose box - Offline attachment disappears after app relaunch before sync[/+]melvin-bot commentedon May 4, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022051370070235891983
neerajbachani commentedon May 4, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-05-04 18:44:03 UTC.
Proposal
What is the root cause of that problem?
On Android, chat attachments are created in a temporary cache path (
cachesDirectory) by the picker flow.When the app is force-killed while still offline, that temporary file may not survive process restart.
Two things then break together:
sourcepath), so the request cannot reliably rebuild multipart payload when network returns.So this is a file-lifecycle mismatch: we queue offline work using a non-durable file location.
What changes do you think we should make in order to solve the problem?
Use a durability-first upload path for chat attachments (native only), and keep display cache separate.
Normalize attachment before queuing request
file.uri = durableUri(for optimistic rendering),file.source = durableUri(for offline replay inprepareRequestPayload).Use normalized file everywhere in the same flow
urinow durable).sourcepresent for replay).Keep responsibilities separated
upload staging= reliability for request replay (all MIME types).cacheAttachment= rendering/cache optimization only (do not depend on it for upload durability).Add cleanup lifecycle
Regression coverage
What alternative solutions did you explore? (Optional)
Rely only on existing
cacheAttachmentDrop/clean persisted requests on startup when file is invalid
Patch optimistic preview only
source.Reuse receipt-specific durable logic directly
github-actions commentedon May 4, 2026
oqildev commentedon May 4, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
github-actions commentedon May 4, 2026
38 remaining items
melvin-bot commentedon Jun 23, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Jun 23, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Jun 26, 2026
Payment Summary
Contributor+: @ZhenjaHorbach due $250 via NewDot
^ Test case created. Thx
garrettmknight commentedon Jun 29, 2026
$250 approved for @ZhenjaHorbach