Skip to content

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

@victordidenko

Description

@victordidenko

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;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions