Bug: Race condition in handleTechSourceset_() async callback
Severity: Low
Files: src/js/player.js
Lines: 1689-1703
Description
The this.tech_.any() callback is set up asynchronously. If the tech is disposed before the callback fires, this.tech_ may be false and this.lastSource_ may be invalid, causing errors when accessing this.techGet_('currentSrc') and this.lastSource_.tech.
Affected code
if (!event.src) {
this.tech_.any(['sourceset', 'loadstart'], (e) => {
if (e.type === 'sourceset') {
return;
}
const techSrc = this.techGet_('currentSrc'); // <-- tech_ may be false
this.lastSource_.tech = techSrc; // <-- lastSource_ may be invalid
this.updateSourceCaches_(techSrc);
});
}
Suggested fix
Add a disposed/validity check in the callback:
this.tech_.any(['sourceset', 'loadstart'], (e) => {
if (!this.tech_ || e.type === 'sourceset') {
return;
}
// ...
});
Bug: Race condition in
handleTechSourceset_()async callbackSeverity: Low
Files:
src/js/player.jsLines: 1689-1703
Description
The
this.tech_.any()callback is set up asynchronously. If the tech is disposed before the callback fires,this.tech_may befalseandthis.lastSource_may be invalid, causing errors when accessingthis.techGet_('currentSrc')andthis.lastSource_.tech.Affected code
Suggested fix
Add a disposed/validity check in the callback: