Skip to content

Commit a3cb8df

Browse files
Merge pull request #13 from LayerTwo-Labs/ui-overhaul
UI overhaul / shutdown fix
2 parents 072e6e9 + 2d00a0c commit a3cb8df

File tree

2 files changed

+48
-9
lines changed

2 files changed

+48
-9
lines changed

public/electron.js

+43-9
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ app.whenReady().then(startApp);
661661

662662
let isShuttingDown = false;
663663
let forceKillTimeout;
664-
const SHUTDOWN_TIMEOUT = 30000;
664+
const SHUTDOWN_TIMEOUT = 10000; // Reduced to 10 seconds
665665

666666
async function performGracefulShutdown() {
667667
if (isShuttingDown) return;
@@ -671,12 +671,19 @@ async function performGracefulShutdown() {
671671
mainWindow.webContents.send("shutdown-started");
672672
}
673673

674+
// Start force kill timeout immediately
674675
forceKillTimeout = setTimeout(() => {
675676
console.log("Shutdown timeout reached, forcing quit...");
676677
forceKillAllProcesses();
677678
}, SHUTDOWN_TIMEOUT);
678679

679680
try {
681+
// Clean up power save blocker if active
682+
if (powerSaveBlockerId !== null) {
683+
powerSaveBlocker.stop(powerSaveBlockerId);
684+
powerSaveBlockerId = null;
685+
}
686+
680687
// First handle any active downloads
681688
if (downloadManager) {
682689
const activeDownloads = downloadManager.getDownloads();
@@ -690,25 +697,38 @@ async function performGracefulShutdown() {
690697
}
691698
}
692699

693-
// Then stop running chains
700+
// Then stop running chains with a timeout
694701
if (chainManager) {
695702
const runningChains = Object.keys(chainManager.runningProcesses);
696-
await Promise.all(runningChains.map(chainId =>
697-
chainManager.stopChain(chainId).catch(err =>
698-
console.error(`Error stopping ${chainId}:`, err)
699-
)
700-
));
703+
await Promise.race([
704+
Promise.all(runningChains.map(chainId =>
705+
chainManager.stopChain(chainId).catch(err =>
706+
console.error(`Error stopping ${chainId}:`, err)
707+
)
708+
)),
709+
new Promise(resolve => setTimeout(resolve, 5000)) // 5 second timeout for chain stopping
710+
]);
701711
}
702712

703713
clearTimeout(forceKillTimeout);
704-
app.quit();
714+
process.nextTick(() => app.exit(0)); // Force exit on next tick
705715
} catch (error) {
706716
console.error("Error during graceful shutdown:", error);
707717
forceKillAllProcesses();
708718
}
709719
}
710720

711721
function forceKillAllProcesses() {
722+
// Clean up power save blocker if active
723+
if (powerSaveBlockerId !== null) {
724+
try {
725+
powerSaveBlocker.stop(powerSaveBlockerId);
726+
powerSaveBlockerId = null;
727+
} catch (error) {
728+
console.error("Error stopping power save blocker:", error);
729+
}
730+
}
731+
712732
// First cancel all downloads
713733
if (downloadManager) {
714734
const activeDownloads = downloadManager.getDownloads();
@@ -727,6 +747,7 @@ function forceKillAllProcesses() {
727747
Object.entries(chainManager.runningProcesses).forEach(([chainId, process]) => {
728748
try {
729749
if (process.kill) {
750+
console.log(`Force killing process for ${chainId}`);
730751
process.kill('SIGKILL');
731752
}
732753
} catch (error) {
@@ -738,7 +759,20 @@ function forceKillAllProcesses() {
738759
if (forceKillTimeout) {
739760
clearTimeout(forceKillTimeout);
740761
}
741-
app.quit();
762+
763+
// Force exit the app
764+
process.nextTick(() => {
765+
try {
766+
// On Linux/Windows, ensure all child processes are terminated
767+
if (process.platform !== 'darwin') {
768+
process.kill(-process.pid, 'SIGKILL');
769+
}
770+
app.exit(0);
771+
} catch (error) {
772+
console.error("Error during force exit:", error);
773+
process.exit(1);
774+
}
775+
});
742776
}
743777

744778
app.on("window-all-closed", () => {

src/components/Nodes.module.css

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
box-sizing: border-box;
1616
}
1717

18+
/* Add margin to the last chain section */
19+
.chainSection:last-child {
20+
margin-bottom: calc(var(--base-spacing) * 2);
21+
}
22+
1823
.chainHeading {
1924
font-size: calc(var(--base-font-size) * 1.1);
2025
font-weight: bold;

0 commit comments

Comments
 (0)