File tree Expand file tree Collapse file tree 2 files changed +23
-9
lines changed
Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -209,13 +209,23 @@ export class AssetPromise<T> implements PromiseLike<T> {
209209 }
210210
211211 /**
212- * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
213- * resolved value cannot be modified from the callback.
214- * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
215- * @returns A Promise for the completion of the callback.
212+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected).
213+ * The callback result is ignored and the original value/reason is preserved per Promise spec.
214+ * Returns an AssetPromise to keep chainability with AssetPromise methods.
215+ * @param onFinally - The callback to execute when the Promise is settled.
216+ * @returns An AssetPromise for the completion of the callback.
216217 */
217- finally ( onFinally ?: ( ) => void ) : Promise < T > {
218- return this . _promise . finally ( onFinally ) ;
218+ finally ( onFinally ?: ( ) => void ) : AssetPromise < T > {
219+ return this . then (
220+ ( value ) => {
221+ onFinally ?.( ) ;
222+ return value ;
223+ } ,
224+ ( reason ) => {
225+ onFinally ?.( ) ;
226+ throw reason ;
227+ }
228+ ) ;
219229 }
220230
221231 /**
Original file line number Diff line number Diff line change @@ -158,9 +158,13 @@ export class GLTFParserContext {
158158 _addTaskCompletePromise ( taskPromise : AssetPromise < any > ) : void {
159159 const task = this . _progress . taskComplete ;
160160 task . total += 1 ;
161- taskPromise . finally ( ( ) => {
162- this . _setTaskCompleteProgress ( ++ task . loaded , task . total ) ;
163- } ) ;
161+ taskPromise
162+ . finally ( ( ) => {
163+ this . _setTaskCompleteProgress ( ++ task . loaded , task . total ) ;
164+ } )
165+ . catch ( ( e ) => {
166+ // Need catch to avoid unhandled rejection
167+ } ) ;
164168 }
165169
166170 private _handleSubAsset < T > (
You can’t perform that action at this time.
0 commit comments