The following code generates the error: Review this usage of “deviceList” as it can only be empty here.
let deviceList
try {
deviceList = await navigator.mediaDevices.enumerateDevices()
} catch (error) {
deviceList = []
console.warn('devices access not allowed', error)
}
const toDevice = device => ({
deviceId: device.deviceId,
label: device.label
})
const devices = {
audio: deviceList.filter(device => device.kind === 'audioinput').map(toDevice),
video: deviceList.filter(device => device.kind === 'videoinput').map(toDevice),
audiooutput: deviceList.filter(device => device.kind === 'audiooutput').map(toDevice)
}
deviceList may be empty, but not always.