π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Recover from FFmpeg utility process crashes
Manav Rathicc2fd5074ac2
diff --git a/desktop/src/main/services/workers.ts b/desktop/src/main/services/workers.tsindex ad07f260f8..ce8b9a852b 100644--- a/desktop/src/main/services/workers.ts+++ b/desktop/src/main/services/workers.ts@@ -244,7 +244,11 @@ const createFFmpegUtilityProcessEndpoint = () => {// Promise.withResolvers is currently in the node available to us.let resolve: ((endpoint: Endpoint) => void) | undefined;- const promise = new Promise<Endpoint>((r) => (resolve = r));+ let reject: ((e: Error) => void) | undefined;+ const promise = new Promise<Endpoint>((res, rej) => {+ resolve = res;+ reject = rej;+ });const { port1, port2 } = new MessageChannelMain();@@ -276,6 +280,15 @@ const createFFmpegUtilityProcessEndpoint = () => {_utilityProcessFFmpeg = child;+ // Recover from crashes: reject the endpoint promise if it is still+ // pending, and clear the cached values so that the next FFmpeg operation+ // spawns a new utility process.+ child.on("exit", () => {+ reject?.(new Error("The FFmpeg utility process exited"));+ _utilityProcessFFmpeg = undefined;+ _utilityProcessFFmpegEndpoint = undefined;+ });+// Resolve with the other end of the message channel (once we get an "ack"// from the utility process).return promise;