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-07-16] [$250] web-Attachment-Attach image offline and refresh page, the attachment fails to load #93375
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
When an attachment is uploaded offline, the optimistic message embeds the file's in-memory blob: URL (web) / file:// URI (native) as the image source, and the AddAttachment request carries the raw File object. Neither survives a page reload, so after a refresh the image points at a dead URL and the upload request is gone — the attachment is permanently stranded.
The two layers that drop the data:
The optimistic HTML hard-codes the volatile local URI as the canonical source.getUploadingAttachmentHtml builds <img src="${file.uri}" data-expensify-source="${file.uri}" .../> where file.uri is a blob:/file: URL. This HTML is persisted to Onyx via buildOptimisticAddCommentReportAction. The report action survives the reload, but a blob: URL is only valid for the lifetime of the page that created it — after refresh it is dangling, so AttachmentView fails to load it and shows "Attachment not found".
The request queue intentionally cannot persist File/Blob objects.shouldPersistOngoingRequest returns false whenever request.data contains a File/Blob, and the code comment acknowledges this is a hard limitation: "IndexedDB cannot clone native File objects (DataCloneError). These requests cannot survive a crash anyway since File references are lost on restart." So the queued upload is never replayed when the user comes back online.
The user sees a silent blank image (not a red-brick failure) because the optimistic action keeps pendingAction: 'add' forever while its underlying upload request has silently vanished.
Failure timeline
Offline — pick file → optimistic action stored with src="blob:..."; API.write('AddAttachment', {file, ...}) pushes a request whose data.file is a File object.
The File is not structured-cloneable, so the persisted queue copy loses the binary (or the persist is skipped entirely).
Refresh (still offline) — Onyx rehydrates the optimistic action (plain JSON, dead blob: src), but the upload request's file is gone.
Back online + refresh — queue flushes whatever remains; the upload never replays. Image is blank → click → "Attachment not found".
What changes do you think we should make in order to solve the problem?
Make the offline attachment durable across a reload by persisting the file bytes (not the volatile File/blob: reference):
When an attachment is queued offline, write the file contents to a reload-safe store (e.g. read into an ArrayBuffer/base64 and store it under a dedicated Onyx key keyed by the optimistic attachmentID). On app start, reconstruct a File/Blob from that stored data and re-hydrate both the queued AddAttachment request's data.file and a fresh object URL for the optimistic action's source, so the upload replays and the preview renders.
Clean up the stored bytes once the server confirms the upload (the real AddAttachment response replaces the optimistic source with the server URL).
Minimum viable alternative if full persistence is out of scope: detect on app start that an optimistic attachment action exists whose source is a now-invalid blob:/file: URL with no replayable upload request, and mark it failed (errored pendingAction) so the user gets a clear retry affordance instead of a silently broken image.
What alternative solutions did you explore? (Optional)
Storing the attachment in IndexedDB as a Blob directly (IndexedDB can store Blobs; the current limitation is specifically Onyx's JSON/structured-clone path on the request queue) and looking it up by attachmentID on reload.
Blocking/queuing the optimistic preview behind a "will upload when online" state and surfacing a non-destructive pending indicator that survives reload.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/93375) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
The problem is the read-back. The optimistic action (with its blob: src) is persisted in Onyx, so it survives a reload — but the browser revokes every blob: object URL when the page unloads, so after a refresh that src resolves to nothing. The inline thumbnail goes blank, and opening it hands the same dead blob: URL to the attachment modal → "Attachment not found".
The cache has a retrieval half built exactly for this — getCachedAttachment, which rebuilds a fresh object URL from the cached bytes for a given attachmentID:
Log.warn('[AttachmentCache] Failed to get attachment',{error});
returncurrentSource;
}
}
…but it is exported and never called anywhere in the app. The bytes get cached on upload, yet nothing ever reads them back, so the dead blob: URI is all that remains after reload.
What changes do you think we should make in order to solve the problem?
Wire getCachedAttachment into source resolution. When an attachment carries an attachmentID and its current source is a local blob:/file: URI (or fails to load), resolve the displayed source from the cache via getCachedAttachment(attachmentID, …) and render the returned object URL instead of the stale src.
Do it at the shared point both render paths read from — best as a small hook (e.g. useCachedAttachmentSource(attachmentID, source)) used in:
the inline chat thumbnail, where ImageRenderer currently passes only the raw blob: src to ThumbnailImage and never forwards attachmentID:
This fixes both the blank preview and the "Attachment not found" modal from the one cache lookup.
What alternative solutions did you explore? (Optional)
On web, also persist a stable source for the attachment (mirroring how the native cache stores a source filepath) and read that back on render. But the bytes are already in CacheStorage, so simply calling the existing getCachedAttachment is the smaller, single-source-of-truth change.
changed the title [-]web-Attachment-Attach image offline and refresh page, the attachment fails to load[/-][+][$250] web-Attachment-Attach image offline and refresh page, the attachment fails to load[/+]on Jun 12, 2026
⚠️@ahmdshrif 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.
⚠️@lorretheboy Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).
@lorretheboy can you please accept the job below? Please reply here and tag me once you have.
If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal. https://www.upwork.com/jobs/~022078257864148756245
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
applause-bot commentedon Jun 12, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/88d7a4d36918c2a0171aae72bcf01fba4ec5916392cc5c38b96b124b2c8c91cd
https://platform.applause.com/services/links/v1/external/e672a5138eac4223a5e403043e0f214fb7a58548b16cd5da05f1e26015d04f34
MelvinBot commentedon Jun 12, 2026
Proposal
What is the root cause of that problem?
When an attachment is uploaded offline, the optimistic message embeds the file's in-memory
blob:URL (web) /file://URI (native) as the image source, and theAddAttachmentrequest carries the rawFileobject. Neither survives a page reload, so after a refresh the image points at a dead URL and the upload request is gone — the attachment is permanently stranded.The two layers that drop the data:
The optimistic HTML hard-codes the volatile local URI as the canonical source.
getUploadingAttachmentHtmlbuilds<img src="${file.uri}" data-expensify-source="${file.uri}" .../>wherefile.uriis ablob:/file:URL. This HTML is persisted to Onyx viabuildOptimisticAddCommentReportAction. The report action survives the reload, but ablob:URL is only valid for the lifetime of the page that created it — after refresh it is dangling, soAttachmentViewfails to load it and shows "Attachment not found".The request queue intentionally cannot persist
File/Blobobjects.shouldPersistOngoingRequestreturnsfalsewheneverrequest.datacontains aFile/Blob, and the code comment acknowledges this is a hard limitation: "IndexedDB cannot clone native File objects (DataCloneError). These requests cannot survive a crash anyway since File references are lost on restart." So the queued upload is never replayed when the user comes back online.The user sees a silent blank image (not a red-brick failure) because the optimistic action keeps
pendingAction: 'add'forever while its underlying upload request has silently vanished.Failure timeline
src="blob:...";API.write('AddAttachment', {file, ...})pushes a request whosedata.fileis aFileobject.Fileis not structured-cloneable, so the persisted queue copy loses the binary (or the persist is skipped entirely).blob:src), but the upload request's file is gone.What changes do you think we should make in order to solve the problem?
Make the offline attachment durable across a reload by persisting the file bytes (not the volatile
File/blob:reference):ArrayBuffer/base64 and store it under a dedicated Onyx key keyed by the optimisticattachmentID). On app start, reconstruct aFile/Blobfrom that stored data and re-hydrate both the queuedAddAttachmentrequest'sdata.fileand a fresh object URL for the optimistic action's source, so the upload replays and the preview renders.AddAttachmentresponse replaces the optimistic source with the server URL).Minimum viable alternative if full persistence is out of scope: detect on app start that an optimistic attachment action exists whose source is a now-invalid
blob:/file:URL with no replayable upload request, and mark it failed (erroredpendingAction) so the user gets a clear retry affordance instead of a silently broken image.What alternative solutions did you explore? (Optional)
Blobdirectly (IndexedDB can storeBlobs; the current limitation is specifically Onyx's JSON/structured-clone path on the request queue) and looking it up byattachmentIDon reload.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/93375)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
lorretheboy commentedon Jun 12, 2026
Proposal
What is the root cause of that problem?
When an attachment is uploaded offline, the optimistic comment is built with an
<img src>that points at a localblob:(web) /file:URI:App/src/libs/ReportUtils.ts
Lines 6037 to 6050 in 23e38e8
In parallel,
addActionssaves the real bytes into a persistent cache (CacheStorage on web, the filesystem on native) keyed byattachmentID:App/src/libs/actions/Report/index.ts
Lines 857 to 864 in 23e38e8
The problem is the read-back. The optimistic action (with its
blob:src) is persisted in Onyx, so it survives a reload — but the browser revokes everyblob:object URL when the page unloads, so after a refresh that src resolves to nothing. The inline thumbnail goes blank, and opening it hands the same deadblob:URL to the attachment modal → "Attachment not found".The cache has a retrieval half built exactly for this —
getCachedAttachment, which rebuilds a fresh object URL from the cached bytes for a givenattachmentID:App/src/libs/actions/Attachment/index.ts
Lines 46 to 67 in 23e38e8
…but it is exported and never called anywhere in the app. The bytes get cached on upload, yet nothing ever reads them back, so the dead
blob:URI is all that remains after reload.What changes do you think we should make in order to solve the problem?
Wire
getCachedAttachmentinto source resolution. When an attachment carries anattachmentIDand its current source is a localblob:/file:URI (or fails to load), resolve the displayed source from the cache viagetCachedAttachment(attachmentID, …)and render the returned object URL instead of the stale src.Do it at the shared point both render paths read from — best as a small hook (e.g.
useCachedAttachmentSource(attachmentID, source)) used in:the inline chat thumbnail, where
ImageRenderercurrently passes only the rawblob:src toThumbnailImageand never forwardsattachmentID:App/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx
Lines 55 to 90 in 23e38e8
the opened attachment, where
AttachmentViewalready receivesattachmentIDbut still renders the rawsource:App/src/components/Attachments/AttachmentView/index.tsx
Lines 113 to 114 in 23e38e8
This fixes both the blank preview and the "Attachment not found" modal from the one cache lookup.
What alternative solutions did you explore? (Optional)
On web, also persist a stable source for the attachment (mirroring how the native cache stores a
sourcefilepath) and read that back on render. But the bytes are already in CacheStorage, so simply calling the existinggetCachedAttachmentis the smaller, single-source-of-truth change.melvin-bot commentedon Jun 12, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ZhenjaHorbach (
External)ahmdshrif commentedon Jun 12, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
melvin-bot commentedon Jun 12, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022065274209562742465
[-]web-Attachment-Attach image offline and refresh page, the attachment fails to load[/-][+][$250] web-Attachment-Attach image offline and refresh page, the attachment fails to load[/+]github-actions commentedon Jun 12, 2026
github-actions commentedon Jun 12, 2026
78 remaining items
melvin-bot commentedon Jul 15, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Jul 15, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Jul 17, 2026
Payment Summary
Contributor: @lorretheboy paid $250 via Upwork
Contributor+: @ZhenjaHorbach due $250 via NewDot
@lorretheboy can you please accept the job below? Please reply here and tag me once you have.
If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal.
https://www.upwork.com/jobs/~022078257864148756245
^ Test case created. Thx
lorretheboy commentedon Jul 18, 2026
@mallenexpensify Thanks. I accepted the job
mallenexpensify commentedon Jul 20, 2026
@lorretheboy paid, summary updated above. Thx.
garrettmknight commentedon Aug 4, 2026
$250 approved for @ZhenjaHorbach