openverse-frontend icon indicating copy to clipboard operation
openverse-frontend copied to clipboard

AudioElement.play()'s promise is not properly handled when erroring

Open sarayourfriend opened this issue 3 years ago • 3 comments

Description

We do not fully handle the promise returned by the AudioElement's play function: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play#return_value

We need to resolve errors in the promise by catching and handling them. We should not assume that the audio will play without issue.

https://sentry.io/share/issue/ba82b7f580074af3901151497c1ef3e2/

Reproduction

  1. Go to https://search.openverse.engineering/search/audio?q=birds and open your browser's developer console
  2. Quickly play and then pause an audio file before it has time to load. Note the error message in your console.

Resolution

  • [ ] 🙋 I would be interested in resolving this bug.

sarayourfriend avatar Aug 01 '22 16:08 sarayourfriend

🙋 I would be interested in resolving this bug.

ramadanomar avatar Aug 03 '22 06:08 ramadanomar

Thanks @ramadanomar :tada: I've assigned the issue to you.

sarayourfriend avatar Aug 03 '22 11:08 sarayourfriend

Noting that this also impacts audio files that are invalid, not just the condition identified in reproduction step 2.

zackkrida avatar Aug 17 '22 00:08 zackkrida