From 3a9c875e03b3ab061f7e86d07c23044b58b6309c Mon Sep 17 00:00:00 2001 From: Lawrence Lomax Date: Tue, 1 Feb 2022 04:55:51 -0800 Subject: [PATCH] Avoid double recording in iOSDevice Summary: This should in theory never happen since the state of the recording is also managed within the UI. However, it's better to ensure that if `startRecording` is called twice, without calling `stopRecording` first it will error rather than leak a recording (the first process will still run but the object representing it is oprhaned) Reviewed By: passy Differential Revision: D33913298 fbshipit-source-id: f8fa6b0e4fdbdf4282633fa29a736d3e7dedf3bb --- desktop/flipper-server-core/src/devices/ios/IOSDevice.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/desktop/flipper-server-core/src/devices/ios/IOSDevice.tsx b/desktop/flipper-server-core/src/devices/ios/IOSDevice.tsx index 5a2a52a8a..3a238ab87 100644 --- a/desktop/flipper-server-core/src/devices/ios/IOSDevice.tsx +++ b/desktop/flipper-server-core/src/devices/ios/IOSDevice.tsx @@ -81,6 +81,12 @@ export default class IOSDevice extends ServerDevice { } async startScreenCapture(destination: string) { + const recording = this.recording; + if (recording) { + throw new Error( + `There is already an active recording at ${recording.destination}`, + ); + } const process = this.iOSBridge.recordVideo(this.serial, destination); this.recording = {process, destination}; }