From 76f5ef188abe009adfe86e0b7c505ecd6720d5e5 Mon Sep 17 00:00:00 2001 From: Andrew Zambazos Date: Thu, 1 Jan 2026 00:34:57 +1300 Subject: [PATCH] Refactor Steam callback cleanup on app exit Simplified the cleanup logic for Steam callback pump by removing unnecessary try-catch and optional chaining. The cleanup is now directly registered after requiring Electron modules. --- main.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/main.js b/main.js index 8c7c5d4..0047011 100644 --- a/main.js +++ b/main.js @@ -127,20 +127,18 @@ function initializeSteamworks() { // This is critical for Steam Input to recognize native controller support initializeSteamworks(); -// Cleanup Steam callback pump on exit -try { - app?.once?.('before-quit', () => { - if (steamCallbacksInterval) { - clearInterval(steamCallbacksInterval); - steamCallbacksInterval = null; - } - try { - steamInput?.shutdown?.(); - } catch {} - }); -} catch {} - const { app, BrowserWindow, ipcMain, session, screen, shell, dialog, Menu, clipboard, webContents } = require('electron'); + +// Cleanup Steam callback pump on exit +app.once('before-quit', () => { + if (steamCallbacksInterval) { + clearInterval(steamCallbacksInterval); + steamCallbacksInterval = null; + } + try { + steamInput?.shutdown?.(); + } catch {} +}); const { autoUpdater } = require('electron-updater'); const { pathToFileURL } = require('url'); const fs = require('fs');