From aeaa832bdda9e7c397b1d2f39fe7a79001f26de3 Mon Sep 17 00:00:00 2001 From: Edwin Joassart Date: Fri, 18 Jul 2025 18:19:43 +0200 Subject: [PATCH] fixes --- lib/shared/sudo/windows.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/shared/sudo/windows.ts b/lib/shared/sudo/windows.ts index 122c9c8e..ad9fb3ed 100644 --- a/lib/shared/sudo/windows.ts +++ b/lib/shared/sudo/windows.ts @@ -106,22 +106,25 @@ export async function sudo( }); // we don't spawn directly in the promise otherwise resolving stop the process + return new Promise((resolve, reject) => { - setInterval(() => { + const checkElevation = setInterval(() => { if (result.status === 'waiting') { - // Still waiting for user input, don't resolve or reject yet return; } else if (result.status === 'granted') { - // User accepted the UAC prompt, process started + clearInterval(checkElevation); resolve({ cancelled: false }); } else if (result.status === 'cancelled') { - // User cancelled the UAC prompt + clearInterval(checkElevation); resolve({ cancelled: true }); - } else { - // An error occurred, reject the promise - reject(new Error(`Elevation failed: ${result.status}`)); } }, 300); + + // if the elevation didn't occured in 30 seconds we reject the promise + setTimeout(() => { + clearInterval(checkElevation); + reject(new Error('Elevation timeout')); + }, 30000); }); } catch (error) { throw new Error(`Can't elevate process ${error}`);