fix: throw on non-OK response in downloadMedia (Fixes JAVASCRIPT-REACT-B)
CI / Build & Quality Checks (push) Successful in 10m23s

When the server returns a 4xx/5xx, downloadMedia was silently returning
the error response body as a blob. decryptAttachment would then fail with
a misleading 'Mismatched SHA-256 digest' instead of surfacing the real
HTTP error. Now throws immediately so callers (useAsyncCallback) can
show the correct error state.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-23 20:38:24 -04:00
parent 15a54eca4b
commit 84fcc161ea
+1
View File
@@ -299,6 +299,7 @@ export const mxcUrlToHttp = (
export const downloadMedia = async (src: string): Promise<Blob> => {
// this request is authenticated by service worker
const res = await fetch(src, { method: 'GET' });
if (!res.ok) throw new Error(`Media download failed: ${res.status} ${res.statusText}`);
const blob = await res.blob();
return blob;
};