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

Extra return in minified JS causing "unreachable code after return statement" #8684

Open
lipupini opened this issue Apr 14, 2024 · 4 comments

Comments

@lipupini
Copy link

Description

There appears to be an odd issue with the minification process. An extra return statement is causing "unreachable code after return statement," reported to me at video.min.js:38:146220

image

You can find it here: http://vjs.zencdn.net/8.10.0/video.min.js
By searching for the string return Vl(o);return}}setDuration

I believe the specific setDuration reference is from around line 57,340 in the unminified version and perhaps it's getting mixed up in the buffered() method that comes directly before it. When I remove the extra return manually from a bundled minified version it works perfectly without error or warning.

Reduced test case

https://jsfiddle.net/7bhg3j68/

Steps to reproduce

  1. Include https://vjs.zencdn.net/8.10.0/video.min.js
  2. Load page in Firefox and check console

Errors

No response

What version of Video.js are you using?

8.10.0

Video.js plugins used.

None

What browser(s) including version(s) does this occur with?

Firefox 124

What OS(es) and version(s) does this occur with?

Linux

@lipupini lipupini added the needs: triage This issue needs to be reviewed label Apr 14, 2024
Copy link

welcome bot commented Apr 14, 2024

👋 Thanks for opening your first issue here! 👋

If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.

@mister-ben
Copy link
Contributor

It's at this line, bufferIntersection in minified and inlined https://github.com/videojs/http-streaming/blob/ceb780aa8558b1bee63c94cc7991b511eda64967/src/source-updater.js#L653. It's benign in this case as it's only a return statement that is unreachable.

buffered() {
  var e = ou(this.mediaSource, this.videoBuffer) ? this.videoBuffer : null,
    t = ou(this.mediaSource, this.audioBuffer) ? this.audioBuffer : null;
  if (t && !e) return this.audioBuffered();
  if (e && !t) return this.videoBuffered();
  {
    var r = this.audioBuffered();
    var n = this.videoBuffered();
    let e = null,
      t = null,
      i = 0;
    var a = [],
      o = [];
    if (!(r && r.length && n && n.length)) return Vl();
    let s = r.length;
    for (; s--; ) a.push({ time: r.start(s), type: "start" }), a.push({ time: r.end(s), type: "end" });
    for (s = n.length; s--; ) a.push({ time: n.start(s), type: "start" }), a.push({ time: n.end(s), type: "end" });
    for (
      a.sort(function (e, t) {
        return e.time - t.time;
      }),
        s = 0;
      s < a.length;
      s++
    )
      "start" === a[s].type ? 2 === ++i && (e = a[s].time) : "end" === a[s].type && 1 === --i && (t = a[s].time), null !== e && null !== t && (o.push([e, t]), (e = null), (t = null));
    return Vl(o);
    return;
  }
}
setDuration(e, t = tu) {
  du({ type: "mediaSource", sourceUpdater: this, action: lu.duration(e), name: "duration", doneFn: t });
}

@lipupini
Copy link
Author

It's benign, but does cause a warning in the console and I wonder why it would add the extra return statement

@mister-ben mister-ben added confirmed and removed needs: triage This issue needs to be reviewed labels Apr 19, 2024
@mister-ben
Copy link
Contributor

We need to look at switching the minifier we are using.

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

No branches or pull requests

2 participants