mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
Release failed asset responses and refuse cancelled requests
This commit is contained in:
1 parent
92526e9a92
commit
f558a240d1
2 files changed
+30
-1
No files matched your search
@@ -19,6 +19,7 @@ export function createAssetDirectorySource({
|
||||
);
|
||||
return async ({ path, signal, maxBytes = PACK_LIMITS.bytes }) => {
|
||||
validateAssetPath(path);
|
||||
signal?.throwIfAborted();
|
||||
const response = await fetchImpl(new URL(path, base).href, {
|
||||
signal,
|
||||
credentials: 'omit',
|
||||
@@ -26,7 +27,10 @@ export function createAssetDirectorySource({
|
||||
referrerPolicy: 'no-referrer',
|
||||
cache: 'no-store',
|
||||
});
|
||||
if (!response.ok) throw new Error('Asset unavailable');
|
||||
if (!response.ok) {
|
||||
await response.body?.cancel().catch(() => {});
|
||||
throw new Error('Asset unavailable');
|
||||
}
|
||||
const reader = response.body?.getReader();
|
||||
if (!reader) throw new Error('Asset stream unavailable');
|
||||
const chunks = [];
|
||||
|
||||
Reference in new issue
Block a user