Problems in renderer process with contextIsolation: true
See original GitHub issue- Review the documentation: https://docs.sentry.io/platforms/javascript/electron/
- Search for existing issues: https://github.com/getsentry/sentry-electron/issues
- Use the latest release: https://github.com/getsentry/sentry-electron/releases
- Provide a link to the affected event from your Sentry account
Versions + Platform
- SDK version -
@sentry/electron@v2.4.0
- Electron version -
electron@v12.0.2
- Platform -
Windows/macOS/Linux
Description
I’m facing two issues with exceptions occurring in a web page loaded in BrowserWindow started with contextIsolation: true
and nodeIntegration: false
(Sentry is initialized as the first thing in a preload script):
- Unhandled exceptions are not sent to Sentry at all – maybe the
'error'
event handler is not working when set up in the isolated context - To capture exceptions manually, I expose
Sentry.captureException
inwindow
bycontextBridge.exposeInMainWorld
, but any exception passed to it goes through the context isolation machinery, which creates a new Error object that only has a message property – stacktrace and error type is lost.
How should we deal with this? Loading and initializing only @sentry/browser in the actual webpage instead of the preload script would work, but then we lose all Electron breadcrumbs etc.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:11
Top Results From Across the Web
With contextIsolation = true, is it possible to use ipcRenderer?
You are still able to use ipcRenderer in a renderer process with contextIsolation set to true. The contextBridge is what you want to...
Read more >Some ipc messages are not sent when contextIsolation and ...
Expected behavior. ipc messages from the main process should be sent to the renderer process when both sandbox and contextIsolation are set.
Read more >Context Isolation - Electron
Exposing APIs from your preload script to a loaded website in the renderer process is a common use-case. With context isolation disabled, your...
Read more >@lpfreelance/electron-bridge - npm
Safely expose main process modules of Electron to renderer ... nativeWindowOpen: true, nodeIntegration: false, contextIsolation: true, ...
Read more >The ultimate Electron guide - Debug & Release
The property that allowed us to include Node in the renderer process is nodeIntegration: true. This made our code easy - our front...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, I guess I wasn‘t very clear. The problem is with errors occurring in the main process, your test case only tests an error in the isolated renderer. I am calling
init
in all three, as per your advice from before, so events get submitted. The issue is that I callin the isolated renderer, and then at some point in the future, if an exception is thrown in the main process and sent to Sentry, it doesn’t have the user info that was provided before.
If I call
in the isolated renderer right after calling
init
, then all errors that occur in main will have that user info, breadcrumbs etc.Does that make sense?
WIth 2.4.1 I still have the same problem. I force the main process to crash, but it still doesn’t get the scope and events from my sentry (react) implementation in the html context.
It seems that sentry-electron and sentry-react don’t work together. I tested it with sentry-electron in the html context instead, and then the scope and events are indeed copied over. Now I have to enable nodeIntegration as a workaround, which I don’t like. Do I have to do something special to integrate sentry-react with sentry-electron?