From dc656e2c0406ce8ce3b7107da0d9a75156607d4a Mon Sep 17 00:00:00 2001 From: Tony Salomone <dadmobile@gmail.com> Date: Fri, 8 Mar 2024 10:52:17 -0500 Subject: [PATCH] Fix crashes that can occur if backend errors during install steps --- src/main/util.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/util.ts b/src/main/util.ts index 13eff3cc..5e2e5d5d 100644 --- a/src/main/util.ts +++ b/src/main/util.ts @@ -158,16 +158,24 @@ export async function checkDependencies() { const options = { shell: '/bin/bash' }; const { stdout, stderr } = await awaitExec(command, options).catch((err) => { console.log('Error running pip list', err); + return { + stdout: false, + stderr: err + }; }); + + // if there was an error abort processing + if (!stdout) { + if (stderr) console.error('stderr:', stderr); + return ["Failed to detect packages"]; + } console.log('stdout:', stdout); - console.error('stderr:', stderr); const pipList = JSON.parse(stdout); const pipListNames = pipList.map((x) => x.name); const keyDependencies = [ 'fastapi', 'pydantic', - 'transformers', 'uvicorn', 'sentencepiece', 'torch', @@ -230,6 +238,10 @@ export async function executeInstallStep( options ).catch((err) => { console.log('Error running install.sh', err); + return { + stdout: false, + stderr: err + }; }); if (stdout) console.log('stdout:', stdout); if (stderr) console.error('stderr:', stderr); @@ -239,6 +251,10 @@ export async function executeInstallStep( options ).catch((err) => { console.log('Error running install.sh', err); + return { + stdout: false, + stderr: err + }; }); if (stdout) console.log('stdout:', stdout); if (stderr) console.error('stderr:', stderr); -- GitLab