fix: improve app initialization error handling#1846
Open
cxybd wants to merge 1 commit intobytedance:mainfrom
Open
fix: improve app initialization error handling#1846cxybd wants to merge 1 commit intobytedance:mainfrom
cxybd wants to merge 1 commit intobytedance:mainfrom
Conversation
✅ Deploy Preview for agent-tars-docs canceled.
|
✅ Deploy Preview for tarko canceled.
|
- Add error dialog to notify users when initialization fails - Log detailed error information for debugging - Ensure app exits cleanly on initialization failure - Prevent app from running in inconsistent state after init errors This fixes the issue where app.whenReady().catch(console.log) would silently swallow initialization errors, leaving the app running in a zombie state with no user feedback. Changes: - Import dialog from electron - Replace console.log with proper error handling - Show user-friendly error dialog with error details - Log full error stack trace for debugging - Call app.quit() to exit cleanly Severity: Critical (8-9/10) Impact: Prevents app from running in inconsistent state, improves UX
33aef95 to
91a5779
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🐛 Problem
Currently, when app initialization fails in
app.whenReady(), the error is only logged to console with.catch(console.log). This causes several critical issues:✅ Solution
Replace the simple
console.logwith proper error handling that:📝 Changes
File:
apps/ui-tars/src/main/main.tsdialogfrom electron.catch(console.log)with comprehensive error handlerapp.quit()to exit the application safelyCode diff:
import { app, BrowserView, BrowserWindow, desktopCapturer, + dialog, ipcMain, session, WebContentsView, screen, } from 'electron'; ... app .whenReady() .then(async () => { await initializeApp(); logger.info('app.whenReady end'); }) - .catch(console.log); + .catch((error) => { + // Log detailed error information + logger.error('Failed to initialize app:', error); + logger.error('Error stack:', error.stack); + + // Show user-friendly error dialog + dialog.showErrorBox( + 'UI-TARS Initialization Failed', + `Failed to start UI-TARS:\n\n${error.message}\n\nPlease check the logs for details.\n\nThe application will now exit.` + ); + + // Exit the application safely + app.quit(); + }); 🧪 Testing ✅ TypeScript compilation: Passes (npm run typecheck) ✅ Code style: Follows project conventions ✅ Type safety: No type errors introduced Expected behavior: On initialization failure, users will see a clear error dialog Detailed logs are written for debugging Application exits cleanly instead of running in broken state 📊 Severity & Impact Severity: Critical (8-9/10) Type: Error handling defect Impact: ✅ Improves user experience - Clear error messaging instead of silent failure ✅ Enhances debuggability - Full error stack traces in logs ✅ Prevents inconsistent state - App doesn't run after initialization failure ✅ Better production stability - Proper error handling for real-world scenarios Risk: Low Only modifies error handling path (catch block) Normal startup flow remains unchanged No breaking changes 🔍 Related Issues Fixes app running in zombie state after initialization failure.