Make _flushOrWaitForOngoingClose set closingPromise (fixes #270)

This commit is contained in:
Vanilagy
2026-01-12 14:36:51 +01:00
parent 1d774b5fbb
commit 78e78e5b4f
2 changed files with 39 additions and 6 deletions
+4 -6
View File
@@ -134,12 +134,10 @@ export abstract class MediaSource {
/** @internal */
async _flushOrWaitForOngoingClose(forceClose: boolean) {
if (this._closingPromise) {
// Since closing also flushes, we don't want to do it twice
return this._closingPromise;
} else {
return this._flushAndClose(forceClose);
}
return this._closingPromise ??= (async () => {
await this._flushAndClose(forceClose);
this._closed = true;
})();
}
}