Skip to content

Commit

Permalink
fix: destroy promise doesn't fullfiled correctly (#122)
Browse files Browse the repository at this point in the history
Issue: promises resolved on different timing and caused the main one to fulfilled
Solution: sync the destroy promise.
  • Loading branch information
Yuvalke committed Nov 24, 2020
1 parent 84d10f2 commit ba82b06
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/dash-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,18 +685,20 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
*/
destroy(): Promise<*> {
this._isDestroyInProgress = true;
return super.destroy().then(() => {
DashAdapter._logger.debug('destroy');
this._loadPromise = null;
return this._reset()
.then(resetResult => {
this._isDestroyInProgress = false;
return resetResult;
})
.catch(error => {
this._isDestroyInProgress = false;
return Promise.reject(error);
});
return new Promise((resolve, reject) => {
super.destroy().then(() => {
DashAdapter._logger.debug('destroy');
this._loadPromise = null;
this._reset()
.then(resetResult => {
this._isDestroyInProgress = false;
resolve(resetResult);
})
.catch(error => {
this._isDestroyInProgress = false;
reject(error);
});
});
});
}

Expand Down

0 comments on commit ba82b06

Please sign in to comment.