fix: Remove download promise when completed

fixes #620
This commit is contained in:
Yotam Mann 2020-02-26 16:05:47 -05:00
parent e68fe68e4c
commit 1539d88ef3

View file

@ -143,11 +143,10 @@ export class ToneAudioBuffer extends Tone {
this.set(audioBuffer);
// invoke the onload method
this.onload(this);
} catch (e) {
// remove the failed file before throwing error
} finally {
// remove the downloaded file
const index = ToneAudioBuffer.downloads.indexOf(promise);
ToneAudioBuffer.downloads.splice(index, 1);
throw e;
}
return this;
}
@ -410,5 +409,7 @@ export class ToneAudioBuffer extends Tone {
for (const promise of ToneAudioBuffer.downloads) {
await promise;
}
// this makes sure that the function is always async
return Promise.resolve();
}
}