Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stopLoad() after destroy() becomes no-op, startLoad() after destroy() throws nicer error message. #3710

Merged
merged 2 commits into from Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/hls.ts
Expand Up @@ -282,16 +282,12 @@ export default class Hls implements HlsEventEmitter {
this.removeAllListeners();
this._autoLevelCapping = -1;
this.url = null;
if (this.networkControllers) {
this.networkControllers.forEach((component) => component.destroy());
// @ts-ignore
this.networkControllers = null;
}
if (this.coreComponents) {
this.coreComponents.forEach((component) => component.destroy());
// @ts-ignore
this.coreComponents = null;
}

this.networkControllers.forEach((component) => component.destroy());
this.networkControllers.length = 0;

this.coreComponents.forEach((component) => component.destroy());
this.coreComponents.length = 0;
}

/**
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/hls.js
@@ -1,5 +1,6 @@
import Hls from '../../src/hls';
import { hlsDefaultConfig } from '../../src/config';
import { expect } from 'chai';

describe('Hls', function () {
describe('bandwidthEstimate', function () {
Expand All @@ -21,4 +22,18 @@ describe('Hls', function () {
);
});
});

describe('destroy', function () {
it('should not crash on stopLoad() after destroy()', function () {
const hls = new Hls();
hls.destroy();
expect(() => hls.stopLoad()).to.not.throw();
});

it('should not crash on startLoad() after destroy()', function () {
const hls = new Hls();
hls.destroy();
expect(() => hls.startLoad()).to.not.throw();
});
});
});