[GH-ISSUE #167] Ask user: Capture error in Sentry when app crashes #52

Closed
opened 2026-10-31 22:08:12 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @robinjhuang on GitHub (Nov 2, 2024).
Original GitHub issue: https://github.com/Comfy-Org/desktop/issues/167

Originally assigned to: @oto-ciulis-tt on GitHub.

Pop up and ask user if they want to send the error and stack to Sentry.


// ... other imports and code ...

// Handle uncaught exceptions
process.on('uncaughtException', async (error) => {
  console.error('Uncaught Exception:', error);
  
  // Show dialog to user
  const response = await dialog.showMessageBox({
    type: 'error',
    title: 'Application Error',
    message: 'An unexpected error occurred.',
    detail: error.stack || error.message,
    buttons: ['Send Error Report', 'Close'],
    defaultId: 0,
    cancelId: 1,
  });

  // Handle user's choice
  if (response.response === 0) {
    // Send error report
    // Add your error reporting logic here
    try {
      await sendErrorReport(error);
    } catch (reportError) {
      console.error('Failed to send error report:', reportError);
    }
  }

  // Gracefully quit the app
  app.quit();
});

// Handle the will-quit event
app.on('will-quit', (event) => {
  // You can prevent quitting here if needed
  // event.preventDefault();
  
  // Perform cleanup
  cleanup();
});

function cleanup() {
  // Add your cleanup logic here
  // Close connections, save state, etc.
}

async function sendErrorReport(error: Error) {
  // Implement your error reporting logic
  // Could be Sentry, custom API, etc.
}
Originally created by @robinjhuang on GitHub (Nov 2, 2024). Original GitHub issue: https://github.com/Comfy-Org/desktop/issues/167 Originally assigned to: @oto-ciulis-tt on GitHub. Pop up and ask user if they want to send the error and stack to Sentry. ```import { app, dialog } from 'electron'; // ... other imports and code ... // Handle uncaught exceptions process.on('uncaughtException', async (error) => { console.error('Uncaught Exception:', error); // Show dialog to user const response = await dialog.showMessageBox({ type: 'error', title: 'Application Error', message: 'An unexpected error occurred.', detail: error.stack || error.message, buttons: ['Send Error Report', 'Close'], defaultId: 0, cancelId: 1, }); // Handle user's choice if (response.response === 0) { // Send error report // Add your error reporting logic here try { await sendErrorReport(error); } catch (reportError) { console.error('Failed to send error report:', reportError); } } // Gracefully quit the app app.quit(); }); // Handle the will-quit event app.on('will-quit', (event) => { // You can prevent quitting here if needed // event.preventDefault(); // Perform cleanup cleanup(); }); function cleanup() { // Add your cleanup logic here // Close connections, save state, etc. } async function sendErrorReport(error: Error) { // Implement your error reporting logic // Could be Sentry, custom API, etc. } ```
bsakaguchi 2026-10-31 22:08:12 +00:00
  • closed this issue
  • added the
    V1
    label
Author
Owner

@robinjhuang commented on GitHub (Nov 4, 2024):

Currently we auto track, but let's move it to a dialog box:

  app.isPackaged &&
    comfySettings.sendCrashStatistics &&
    Sentry.init({
      dsn: SENTRY_URL_ENDPOINT,
      autoSessionTracking: false,
      integrations: [
        Sentry.childProcessIntegration({
          breadcrumbs: ['abnormal-exit', 'killed', 'crashed', 'launch-failed', 'oom', 'integrity-failure'],
          events: ['abnormal-exit', 'killed', 'crashed', 'launch-failed', 'oom', 'integrity-failure'],
        }),
      ],
    });
<!-- gh-comment-id:2455572356 --> @robinjhuang commented on GitHub (Nov 4, 2024): Currently we auto track, but let's move it to a dialog box: ``` app.isPackaged && comfySettings.sendCrashStatistics && Sentry.init({ dsn: SENTRY_URL_ENDPOINT, autoSessionTracking: false, integrations: [ Sentry.childProcessIntegration({ breadcrumbs: ['abnormal-exit', 'killed', 'crashed', 'launch-failed', 'oom', 'integrity-failure'], events: ['abnormal-exit', 'killed', 'crashed', 'launch-failed', 'oom', 'integrity-failure'], }), ], }); ```
Author
Owner

@robinjhuang commented on GitHub (Nov 19, 2024):

Closed by: github.com/Comfy-Org/desktop@bcf287739b

<!-- gh-comment-id:2486472857 --> @robinjhuang commented on GitHub (Nov 19, 2024): Closed by: https://github.com/Comfy-Org/desktop/commit/bcf287739b1543ed78dce79990e5a76bf450a519
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/desktop#52
No description provided.