We use the Recording
object in the expo-av library to record long recordings. Our code to finish a recording looks like this:
await recordingRef.current.stopAndUnloadAsync();
await Audio.setAudioModeAsync({
allowsRecordingIOS: false,
playsInSilentModeIOS: false,
staysActiveInBackground: false,
});
const uri = recordingRef.current.getURI();
if (!uri) {
throw new Error("Recording stopped but failed to generate URI");
}
const fileInfo = await FileSystem.getInfoAsync(uri);
if (!fileInfo.exists) {
throw new Error(`Recording file not found at ${uri}`);
}
...
A small handful of our users sometimes experience the error Recording file not found at ${uri}
What could cause this? How is it that stopAndUnloadAsync()
can succeed awaited, getURI()
can successfully return a URI but then the resulting file doesn't exist?