question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using sentry-electron with contextIsolation, preload.js, and nodeIntegration off

See original GitHub issue

Hi there!

I’m trying to get errors from renderer.js, where I can’t require/import anything because I have nodeIntegration turned off for security reasons.

I looked at your sample app, but even initializing sentry in the preload.js, I’m still not able to get exceptions from renderer.js. I test this by trying to run a non-existent function in renderer.js, similar to the example you have in the docs.

This is probably a noob-level misunderstanding, but I can’t figure out what I’m supposed to do here, despite reading through a number of issues like this one.

I’m happy to share code, but I’d love an example of exactly what I need to put in renderer.js, preload.js, and main.js/index.js to make this work.

Thank you for making sentry-electron!

Jimmy

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
timfishcommented, Nov 8, 2021

With 3.0.0-beta.1, here is an example in the integration test examples: https://github.com/getsentry/sentry-electron/tree/master/examples/webpack-context-isolation

If you can wait a few days 3.0.0-beta.2 should remove the need for a preload unless you’re bundling the main process code and using Electron < v5: https://github.com/getsentry/sentry-electron/pull/377

1reaction
timfishcommented, Sep 13, 2021

Yes. Unless you bundle your renderer code, you will not be able to use any dependencies in the renderer process with nodeIntegration: false.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Communication between preload and client given context ...
In Electron 5.0.0, context isolation will be enabled by default. To prepare for this change, set {contextIsolation: false} in the webPreferences ...
Read more >
Context Isolation - Electron
Context Isolation is a feature that ensures that both your preload scripts and Electron's internal logic run in a separate context to the...
Read more >
require is not available in "Electron Isolated Context ... - GitHub
As I mentioned, require is available to the preload script when {contextIsolation: true, nodeIntegration: false} and AFAICT that's deliberate.
Read more >
How to Secure a Electron App Using Context Isolation.NO ...
Today we will make our app secure using context isolation inside electron 12. This is a very important topic to developing electron apps...
Read more >
Preloading Insecurity In Your Electron - YouTube
Even without a framework bug (e.g. nodeIntegration bypass), BrowserWindow preload introduces a new interesting attack surface to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found