mirror of
https://github.com/galacean/engine.git
synced 2026-06-04 17:57:13 +08:00
Prevent ResourceManager test failures due to unhandled rejection… (#2812)
* fix: prevent ResourceManager test failures due to unhandled rejection
This commit is contained in:
@@ -209,13 +209,23 @@ export class AssetPromise<T> implements PromiseLike<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
||||
* resolved value cannot be modified from the callback.
|
||||
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
|
||||
* @returns A Promise for the completion of the callback.
|
||||
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected).
|
||||
* The callback result is ignored and the original value/reason is preserved per Promise spec.
|
||||
* Returns an AssetPromise to keep chainability with AssetPromise methods.
|
||||
* @param onFinally - The callback to execute when the Promise is settled.
|
||||
* @returns An AssetPromise for the completion of the callback.
|
||||
*/
|
||||
finally(onFinally?: () => void): Promise<T> {
|
||||
return this._promise.finally(onFinally);
|
||||
finally(onFinally?: () => void): AssetPromise<T> {
|
||||
return this.then(
|
||||
(value) => {
|
||||
onFinally?.();
|
||||
return value;
|
||||
},
|
||||
(reason) => {
|
||||
onFinally?.();
|
||||
throw reason;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -158,9 +158,13 @@ export class GLTFParserContext {
|
||||
_addTaskCompletePromise(taskPromise: AssetPromise<any>): void {
|
||||
const task = this._progress.taskComplete;
|
||||
task.total += 1;
|
||||
taskPromise.finally(() => {
|
||||
this._setTaskCompleteProgress(++task.loaded, task.total);
|
||||
});
|
||||
taskPromise
|
||||
.finally(() => {
|
||||
this._setTaskCompleteProgress(++task.loaded, task.total);
|
||||
})
|
||||
.catch((e) => {
|
||||
// Need catch to avoid unhandled rejection
|
||||
});
|
||||
}
|
||||
|
||||
private _handleSubAsset<T>(
|
||||
|
||||
Reference in New Issue
Block a user