Unhandled promise rejection when loading files

Hello!

This is a small issue really. There’s loadDataAsync function in the sceneLoader.ts file that has an awaited function call (link to source):

// Fetching head content to get the mime type
const response = await _FetchAsync(fileInfo.url, { method: "HEAD", responseHeaders: ["Content-Type"] });

If this request fails for some reason, then the error can’t be handled (e.g. onError callback is not called).

I suppose it should be wrapped in a try/catch (maybe with an empty catch block if missing mimeType can be ignored?).

PG: Babylon.js Playground

Thank you!

UPD: Actually, now I see there’s several other throw new Error statements in loadDataAsync function that can’t be handled, potentially. Shouldn’t those be passed to onError callback?..

Do you want to try a PR? Happy to look at it

1 Like