Browse Source

Fix EPIPE error handling in Electron AppImage

- Added custom error handler for electron-unhandled to suppress EPIPE errors
- Added process.stdout and process.stderr error handlers for EPIPE
- EPIPE errors are common in AppImages due to console output pipe issues
- App now runs cleanly without unhandled error dialogs

Resolves console output errors that were causing unhandled error dialogs
in the distributed AppImage while maintaining proper error logging for
other types of errors.
streamline-attempt
Matthew Raymer 1 week ago
parent
commit
dbfb8074fc
  1. 27
      electron/src/index.ts

27
electron/src/index.ts

@ -9,7 +9,32 @@ import { autoUpdater } from 'electron-updater';
import { ElectronCapacitorApp, setupContentSecurityPolicy, setupReloadWatcher } from './setup';
// Graceful handling of unhandled errors.
unhandled();
unhandled({
logger: (error) => {
// Suppress EPIPE errors which are common in AppImages due to console output issues
if (error.message && error.message.includes('EPIPE')) {
return; // Don't log EPIPE errors
}
console.error('Unhandled error:', error);
}
});
// Handle EPIPE errors on stdout/stderr to prevent crashes
process.stdout.on('error', (err) => {
if (err.code === 'EPIPE') {
// Ignore EPIPE errors on stdout
return;
}
console.error('stdout error:', err);
});
process.stderr.on('error', (err) => {
if (err.code === 'EPIPE') {
// Ignore EPIPE errors on stderr
return;
}
console.error('stderr error:', err);
});
// Define our menu templates (these are optional)
const trayMenuTemplate: (MenuItemConstructorOptions | MenuItem)[] = [new MenuItem({ label: 'Quit App', role: 'quit' })];

Loading…
Cancel
Save