fix: throw on non-OK response in downloadMedia (Fixes JAVASCRIPT-REACT-B)
CI / Build & Quality Checks (push) Successful in 10m23s
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:
@@ -299,6 +299,7 @@ export const mxcUrlToHttp = (
|
|||||||
export const downloadMedia = async (src: string): Promise<Blob> => {
|
export const downloadMedia = async (src: string): Promise<Blob> => {
|
||||||
// this request is authenticated by service worker
|
// this request is authenticated by service worker
|
||||||
const res = await fetch(src, { method: 'GET' });
|
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();
|
const blob = await res.blob();
|
||||||
return blob;
|
return blob;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user