From 00db563fd3e5dd13bbfc506ad95c4c628eb83139 Mon Sep 17 00:00:00 2001 From: samtiz Date: Tue, 8 Jul 2025 01:36:15 +0900 Subject: [PATCH] fix db init issue + add CI workflow --- .github/workflows/build.yml | 34 ++++++++++++++++++++++++++++ src/index.js | 44 +++++++++++++++++++++---------------- 2 files changed, 59 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b8ae04a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,34 @@ +name: Build & Verify + +on: + push: + branches: [ "main" ] # Runs on every push to main branch + +jobs: + build: + # Currently runs on macOS only, can add windows-latest later + runs-on: macos-latest + + steps: + - name: 🚚 Checkout code + uses: actions/checkout@v4 + + - name: ⚙️ Setup Node.js environment + uses: actions/setup-node@v4 + with: + node-version: '20.x' # Node.js version compatible with project + cache: 'npm' # npm dependency caching for speed improvement + + - name: 📦 Install root dependencies + run: npm install + + - name: 🌐 Install and build web (Renderer) part + # Move to pickleglass_web directory and run commands + working-directory: ./pickleglass_web + run: | + npm install + npm run build + + - name: 🖥️ Build Electron app + # Run Electron build script from root directory + run: npm run build \ No newline at end of file diff --git a/src/index.js b/src/index.js index e0fcde4..52c057f 100644 --- a/src/index.js +++ b/src/index.js @@ -165,27 +165,33 @@ app.whenReady().then(async () => { // Initialize core services initializeFirebase(); - databaseInitializer.initialize() - .then(() => { - console.log('>>> [index.js] Database initialized successfully'); - - // Clean up zombie sessions from previous runs first - sessionRepository.endAllActiveSessions(); + try { + await databaseInitializer.initialize(); + console.log('>>> [index.js] Database initialized successfully'); + + // Clean up zombie sessions from previous runs first + sessionRepository.endAllActiveSessions(); - authService.initialize(); - listenService.setupIpcHandlers(); - askService.initialize(); - settingsService.initialize(); - setupGeneralIpcHandlers(); - }) - .catch(err => { - console.error('>>> [index.js] Database initialization failed - some features may not work', err); - }); + authService.initialize(); + listenService.setupIpcHandlers(); + askService.initialize(); + settingsService.initialize(); + setupGeneralIpcHandlers(); - WEB_PORT = await startWebStack(); - console.log('Web front-end listening on', WEB_PORT); - - createWindows(); + // Start web server and create windows ONLY after all initializations are successful + WEB_PORT = await startWebStack(); + console.log('Web front-end listening on', WEB_PORT); + + createWindows(); + + } catch (err) { + console.error('>>> [index.js] Database initialization failed - some features may not work', err); + // Optionally, show an error dialog to the user + dialog.showErrorBox( + 'Application Error', + 'A critical error occurred during startup. Some features might be disabled. Please restart the application.' + ); + } initAutoUpdater();