sentry-electron
sentry-electron copied to clipboard
What's the best practice for handling uncaught exceptions but still passing them to Sentry?
A user of our app got: ENOSPC: no space left on device, write
(issue 868195291, feel free to look)
Sentry breadcrumbs and our electron-log breadcrumbs show this happened soon after the user launched our app (app.browser-window-created). crashed_process
is browser so I think the error happened in the renderer. It's unclear to me if this crashed the app, or caused our main BrowserWindow to fail to launch.
My question is: how can we better handle this error and show a message to the user if their disk is full?
- Should we use
window.onerror
? - Should we use Node.js'
process.on('uncaughtException
)` - If we decide it's a good idea to catch uncaught exceptions ourselves, how to we pass them to Sentry in a manner which preserves all the breadcrumbs, extras, stacktrace, etc.? Will plain ole
Sentry.captureException()
do for catching uncaught exceptions, or is that not advised?
has process.on(uncaughtException)
worked for you? It has not worked for me.
crashed_process
isbrowser
so I think the error happened in the renderer
Unintuitively, browser
is the Electron main process and renderer
is the browser renderer process. These are the terms from Chromium and Electron decided to keep them 😭
It's likely that you'd want to listen to process.on('uncaughtException')
and process.on('unhandledrejection')
.
Submit to Sentry via Sentry.captureException(error)
and call await Sentry.flush()
to ensure that events are sent before exit.