Skip to content

Bug: Race condition in handleTechSourceset_() async callback #9187

Description

@ai-bughunter

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;
  }
  // ...
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions