Skip to content
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

feat: Identify webContents of renderers via custom protocol #762

Merged
merged 6 commits into from Oct 2, 2023

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Oct 2, 2023

The Electron SDK supports two ways for the renderers to send envelopes and scope to the main process.

This has meant custom protocol has not supported all the same context as Electron IPC because we're missing the reference to the webContents.

This is a problem for renderer ANR detection. We should be able to use the Electron debugger API to capture stack traces but once a renderer stops sending us mesages, we need to know which webContents to attach to!

This PR adds a means for us to identify renderers over a custom protocol:

  • In protocol mode, window.__SENTRY_RENDERER_ID__ is set to a uuid
  • When a renderer starts up and pings the main proces via the custom protocol, we use executeJavaScript to fetch the id and save the mapping between id and webContents
  • When the renderer sends events/envelopes/scope and later ANR messages, the id is included in the headers
  • In the main process, we can use the id in the headers to determine which webContents the message came from

@timfish timfish changed the title feat: Identify webContents of custom protocol renderers feat: Identify webContents of renderers via custom protocol Oct 2, 2023
@timfish timfish force-pushed the feat/identify-protocol-renderers branch from e5765cf to 5847942 Compare October 2, 2023 12:43
@timfish timfish force-pushed the feat/identify-protocol-renderers branch from 5847942 to ffd6f67 Compare October 2, 2023 13:12
@timfish timfish self-assigned this Oct 2, 2023
@timfish timfish marked this pull request as ready for review October 2, 2023 13:51
@timfish
Copy link
Collaborator Author

timfish commented Oct 2, 2023

I want to add an extra test for this before merging

@timfish timfish force-pushed the feat/identify-protocol-renderers branch from e0e5b81 to ff98b6d Compare October 2, 2023 15:53
@timfish timfish merged commit a6bf684 into getsentry:master Oct 2, 2023
41 checks passed
@timfish timfish deleted the feat/identify-protocol-renderers branch October 2, 2023 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants