galacean / engine

A typescript interactive engine, support 2D, 3D, animation, physics, built on WebGL and glTF.
https://www.galacean.com/engine
MIT License
4.29k stars 307 forks source link

GLTF loader will not resolve when load cdn url with invalid query `q` #2439

Open Sway007 opened 1 week ago

Sway007 commented 1 week ago

Bug description

below snippets will not resolve

engine.resourceManager
    .load({
      type: AssetType.GLTF,
      url: 'https://mdn.alipayobjects.com/oasis_be/afts/file/A*ZZoRTbS5OocAAAAAAAAAAAAADkp5AQ/6cb8f543-285c-491a-8cfd-57a1160dc9ab.glb?q=invalid',
    })
    .then((item) => {
      console.log('success:', item);
    });

Solution

The value of query q is reserved by ResourceManger for sub assets uri path. Invalid query q will let ResourceManger find an not exist resource, then an never resolve promise is produced.

  1. ResourceManger should validate query q before find sub assets.
  2. ResourceManger should throw an error if failed to find sub assets instead of leaving an unresolved promise.