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().
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:
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.
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:
The catch block needs the same check before calling dataProviderError().