[ts][pixi-v7][pixi-v8] Fix asset loaders not throwing when http response is not ok. See #3042.

This commit is contained in:
Davide Tantillo 2026-03-17 10:25:24 +01:00
parent 80a1f4d38b
commit 592d57f114
4 changed files with 12 additions and 9 deletions

View File

@ -68,9 +68,10 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
async load (url: string): Promise<RawAtlas> {
const response = await settings.ADAPTER.fetch(url);
const txt = await response.text();
if (!response.ok)
throw new Error(`[${loaderName}] Failed to fetch ${url}: ${response.status} ${response.statusText}`);
return txt;
return await response.text();
},
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
@ -106,7 +107,6 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
// we will wait for all promises for the textures at the same time at the end.
const textureLoadingPromises = [];
// setting preferCreateImageBitmap to false for loadTextures loader to allow loading PMA images
let oldPreferCreateImageBitmap = true;
for (const parser of loader.parsers) {

View File

@ -65,9 +65,10 @@ const spineLoaderExtension: AssetExtension<SkeletonJsonAsset | SkeletonBinaryAss
async load (url: string): Promise<SkeletonBinaryAsset> {
const response = await settings.ADAPTER.fetch(url);
const buffer = new Uint8Array(await response.arrayBuffer());
if (!response.ok)
throw new Error(`[${loaderName}] Failed to fetch ${url}: ${response.status} ${response.statusText}`);
return buffer;
return new Uint8Array(await response.arrayBuffer());
},
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
const isJsonSpineModel = checkExtension(options.src as string, ".json") && isJson(asset);

View File

@ -83,9 +83,10 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
async load (url: string): Promise<RawAtlas> {
const response = await DOMAdapter.get().fetch(url);
const txt = await response.text();
if (!response.ok)
throw new Error(`[${loaderName}] Failed to fetch ${url}: ${response.status} ${response.statusText}`);
return txt;
return await response.text();
},
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {

View File

@ -72,9 +72,10 @@ const spineLoaderExtension: AssetExtension<SkeletonJsonAsset | SkeletonBinaryAss
async load (url: string): Promise<SkeletonBinaryAsset> {
const response = await DOMAdapter.get().fetch(url);
const buffer = new Uint8Array(await response.arrayBuffer());
if (!response.ok)
throw new Error(`[${loaderName}] Failed to fetch ${url}: ${response.status} ${response.statusText}`);
return buffer;
return new Uint8Array(await response.arrayBuffer());
},
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
const isJsonSpineModel = checkExtension(options.src as string, '.json') && isJson(asset);