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

Cannot read properties of undefined (reading 'duration') #1559

Open
victordidenko opened this issue Dec 31, 2024 · 4 comments
Open

Cannot read properties of undefined (reading 'duration') #1559

victordidenko opened this issue Dec 31, 2024 · 4 comments

Comments

@victordidenko
Copy link

We have many errors in the Sentry, which looks like this

{
message: Cannot read properties of undefined (reading 'duration'),
name: TypeError,
stack: 
TypeError: Cannot read properties of undefined (reading 'duration')
    at Tf (.../player.js:188:3879)
    at CD.getExpiredTime (.../player.js:218:3581)
    at WD.stuckAtPlaylistEnd_ (.../player.js:218:45386)
    at kh.<anonymous> (.../player.js:218:37265)
    at i.dispatcher.i.dispatcher (.../player.js:23:40858)
    at Qh (.../player.js:23:41677)
    at kh.trigger (.../player.js:23:43393)
    at kh.haveMetadata (.../player.js:188:17321)
    at .../player.js:188:15997
    at Z_ (.../player.js:188:25260)
}

Unfortunately I cannot say conditions for this issue, I've never seen it in dev environment, but it is very frequent (in fact, this is the most repeating error in our Sentry), but from minified code I figured that this is sumDurations function:

durations += durationList[i].duration;

Image

Maybe it is possible to add some kind of a guard here, at least?
Like

durations += durationList[i]?.duration ?? 0;
@adrums86
Copy link
Contributor

adrums86 commented Jan 8, 2025

Do you have an example manifest we could create a reduced test case with? I think we need a little more information to determine what is causing the durationList to be undefined in this case

@victordidenko
Copy link
Author

I will try to find stream, but this may be happen in some circumstances, which are not fully depend on a stream... Unfortunately, Sentry logs from production doesn't show full image, and as I say, I've never seen this error in development environment.

But what could be wrong in adding nullish guard?

@adrums86
Copy link
Contributor

adrums86 commented Jan 9, 2025

Simply trying to understand why this is happening in your environment and not more common elsewhere. Nothing wrong with a nullish guard, feel free to submit a PR. However a quick look at the code suggests there might be a bigger problem with the media if the durationList is undefined. Meaning a nullish guard might only push the problem further down stream. The durationList is generated from the reduce output from the media playlist. See: playlist.js.

@victordidenko
Copy link
Author

The issue is that we provide software for an external company, and do not own streams. I'll ask our QA engineers, if they have access to the client's production server.

Meanwhile, in the Sentry I saw different stacktrace with the similar error:

{
message: Cannot read properties of undefined (reading 'duration'),
name: TypeError,
stack: 
TypeError: Cannot read properties of undefined (reading 'duration')
    at AE.calculateBaseTime_ (.../player.js:218:343)
    at AE.update (.../player.js:215:7438)
    at n0.playlist (.../player.js:203:56263)
    at WD.handleUpdatedMediaPlaylist (.../player.js:218:38102)
    at Ch.<anonymous> (.../player.js:218:36246)
    at i.dispatcher.i.dispatcher (.../player.js:23:40858)
    at Jh (.../player.js:23:41677)
    at Ch.trigger (.../player.js:23:43393)
    at Ch.haveMetadata (.../player.js:188:17546)
    at .../player.js:188:15997
}

This looks like this place:

baseTime -= segment.duration;

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