Skip to content

Disposed player crashes when a data-provider request fails #422

Description

@philippd

If a data-provider request fails after the player has been disposed, Pillarbox still tries to show an error on that player.

This causes an unhandled error:

  TypeError: Cannot read properties of null (reading 'language')
      at Player.localize
      at SrgSsr.dataProviderError
      at SrgSsr.handleSetSource

FYI: In Play+ we got this error reported 28 times in the last two weeks via Sentry.

How to reproduce

Reproduced with @srgssr/pillarbox-web 1.36.2.

   let rejectRequest;

   const player = Pillarbox('player', {
     srgOptions: {
       dataProvider: () =>
         new Promise((_, reject) => {
           rejectRequest = reject;
         }),
     },
   });

   player.src({
     src: 'urn:srf:video:pending',
     type: 'srgssr/urn',
   });

   while (!rejectRequest) {
     await new Promise((resolve) => setTimeout(resolve, 0));
   }

   player.dispose();
   rejectRequest(new Error('Request failed'));

Expected

Pillarbox ignores the request error because the player has already been disposed.

Possible fix

Check player.isDisposed() before using the player after an asynchronous request:

  const srcMediaObj = await this.getSrcMediaObj(player, srcObj);
  if (player.isDisposed()) return;

The catch block needs the same check before calling dataProviderError().

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

    • Status
      📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions