-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: (almost) Entirely remove the need for preload script #376
Comments
Can we monkey patch fetch to attach context from the renderer somehow? |
We can just pass the renderer identifier through with the event. The issue is that in a renderer with The only place we can reliably identify the renderer is in the main process, and the We can identify that the error came from a renderer, we just can't tell exactly which one. However, we could add is as an option to the renderer/browser init: init({
processName: 'main-window'
}) EDIT Currently, users have to keep track of which export interface ElectronMainOptions extends NodeOptions {
/**
* Callback to allow custom naming of renderer processes
* If the callback is not set, or it returns `undefined`, the default naming
* scheme is used.
*/
getRendererName?: (contents: WebContents) => string | undefined;
} |
+1 to adding Feel like this is something we should open an issue about in https://github.com/electron/electron, perhaps we can get a better experience out of the box for future versions. |
I've looked into this a bit further at it looks like we wont be able to remove the existing Out of interest, I did a quick search on Github and couldn't find any public usages of It would be a bit confusing to have both
Yes, I'll do that! |
Problem
Even after the large refactor for v3, the Electron SDK can be a little at odds with Sentry's developer philosophy:
Electron is a complex beast.
Electrons IPC modules are the primary means to communicate between the main and renderer processes. However the tightening of the security model and the many configuration options has made it complex for library authors and their consumers. The only reliable way to expose IPC across all configurations is via
contextBridge
in a preload script. We can make a best effort at injecting preload scripts but this is not compatible with bundlers and instructing users to configure preload scripts with various bundlers is not simple and still leaves outstanding issues (#372 (comment)) unsolved.There is another option!
The
protocol
module allows you to setup a custom protocol from the main process which you can call from a renderer viafetch
.This has a few downsides over IPC:
Proposal
sentry-ipc
protocol in main process when Electron >= v5fetch('sentry-ipc://event-etc')
Unsupported Configurations
When using Electron < v5 while bundling the main process code there is no custom protocol and preload injection will fail. Users will be required to configure a preload script.
Downsides
When users bundle the main process code, the SDK cannot inject preload scripts, will fallback to
fetch
+ custom protocol and you'll loose context over exactly which renderer JavaScript errors come from. The URL/path information is all sill included.Users can negate this by configuring a preload script.
Upsides
Unless you're using Electron < v5 and bundling your main process code, there is no longer a need to care about preload scripts.
The text was updated successfully, but these errors were encountered: