Skip to content

Commit 576d9f2

Browse files
gmaclennanclaude
andauthored
fix: don't report expo-image disk-cache misses for photo storage size (#1951)
getExpoImageStorageSize threw when expo-image's getCachePathAsync returned null (a benign disk-cache miss), and the only caller reported it to Sentry (COMAPEO-20Z). Return number | null and treat null as 'no storage size' in useImageLoadInfo. UI is unchanged (the label was already optional). Making the label always show needs the blob server to send Content-Length: comapeo-core#1281 + #1945. Fixes COMAPEO-20Z. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 373ff31 commit 576d9f2

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/frontend/lib/file-system.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,22 @@ export async function selectFile({
6565
*/
6666
export async function getExpoImageStorageSize(
6767
imageURL: string,
68-
): Promise<number> {
68+
): Promise<number | null> {
6969
let fileInfo: FileSystem.FileInfo;
7070

7171
if (imageURL.startsWith('file://')) {
7272
fileInfo = await FileSystem.getInfoAsync(imageURL);
7373
} else {
7474
const cachePath = await ExpoImage.getCachePathAsync(imageURL);
7575

76-
if (!cachePath) {
77-
throw new Error(`Could not get size for image at ${imageURL}`);
78-
}
76+
// null when the image isn't in expo-image's disk cache (served from memory,
77+
// not yet written, or evicted) — a benign miss, not an error.
78+
if (!cachePath) return null;
7979

8080
fileInfo = await FileSystem.getInfoAsync(`file://${cachePath}`);
8181
}
8282

83-
if (!fileInfo.exists) {
84-
throw new Error(`Could not get size for image at ${imageURL}`);
85-
}
83+
if (!fileInfo.exists) return null;
8684

8785
return fileInfo.size;
8886
}

src/frontend/screens/PhotoPreviewModal/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export function useImageLoadInfo() {
194194
setImageLoadInfo({
195195
height: event.source.height,
196196
width: event.source.width,
197-
storageSize,
197+
storageSize: storageSize ?? undefined,
198198
});
199199
} catch (err) {
200200
captureException(err);

0 commit comments

Comments
 (0)