From f7d6dafd110a1c3489d87ebf6fccf7175e895009 Mon Sep 17 00:00:00 2001 From: David Crespo Date: Wed, 16 Oct 2024 14:09:03 -0500 Subject: [PATCH] How about we don't hold the entire image in memory (#2506) don't cache image upload chunks --- app/forms/image-upload.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/forms/image-upload.tsx b/app/forms/image-upload.tsx index cba8df02d..b7b7dbbbe 100644 --- a/app/forms/image-upload.tsx +++ b/app/forms/image-upload.tsx @@ -215,7 +215,13 @@ export function CreateImageSideModalForm() { const createDisk = useApiMutation('diskCreate') const startImport = useApiMutation('diskBulkWriteImportStart') - const uploadChunk = useApiMutation('diskBulkWriteImport') + + // gcTime: 0 prevents the mutation cache from holding onto all the chunks for + // 5 minutes. It can be a ton of memory. To be honest, I don't even understand + // why the mutation cache exists. It's not like the query cache, which dedupes + // identical queries made around the same time. + // https://tanstack.com/query/v5/docs/reference/MutationCache + const uploadChunk = useApiMutation('diskBulkWriteImport', { gcTime: 0 }) // synthetic state for upload step because it consists of multiple requests const [syntheticUploadState, setSyntheticUploadState] =