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

fix: Duplicate crashed sessions #961

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/main/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,10 @@ export function sessionCrashed(): void {
logger.log('Setting session as crashed');
const errors = session.errors + 1;
updateSession(session, { status: 'crashed', errors });
captureSession();
} else {
logger.log('Session already ended');
}

captureSession();
}

/** Sets the current session as ANR */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"method": "envelope",
"sentryKey": "37f8a2ee37c0409d8970bc7559c7c7e4",
"appId": "277345",
"data": {
"sdk": {
"name": "sentry.javascript.electron",
"packages": [
{
"name": "npm:@sentry/electron",
"version": "{{version}}"
}
],
"version": "{{version}}"
},
"contexts": {
"app": {
"app_name": "session-native-crash-renderer-multiple",
"app_version": "1.0.0",
"app_start_time": "{{time}}"
},
"browser": {
"name": "Chrome"
},
"chrome": {
"name": "Chrome",
"type": "runtime",
"version": "{{version}}"
},
"device": {
"arch": "{{arch}}",
"family": "Desktop",
"memory_size": 0,
"free_memory": 0,
"processor_count": 0,
"processor_frequency": 0,
"cpu_description": "{{cpu}}",
"screen_resolution":"{{screen}}",
"screen_density": 1
},
"culture": {
"locale": "{{locale}}",
"timezone": "{{timezone}}"
},
"node": {
"name": "Node",
"type": "runtime",
"version": "{{version}}"
},
"os": {
"name": "{{platform}}",
"version": "{{version}}"
},
"runtime": {
"name": "Electron",
"version": "{{version}}"
},
"electron": {
"crashed_url": "app:///src/index.html"
}
},
"release": "session-native-crash-renderer-multiple@1.0.0",
"environment": "development",
"event_id": "{{id}}",
"timestamp": 0,
"breadcrumbs": [],
"tags": {
"event.environment": "native",
"event.origin": "electron",
"event.process": "renderer"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"method": "envelope",
"sentryKey": "37f8a2ee37c0409d8970bc7559c7c7e4",
"appId": "277345",
"data": {
"sdk": {
"name": "sentry.javascript.electron",
"packages": [
{
"name": "npm:@sentry/electron",
"version": "{{version}}"
}
],
"version": "{{version}}"
},
"contexts": {
"app": {
"app_name": "session-native-crash-renderer-multiple",
"app_version": "1.0.0",
"app_start_time": "{{time}}"
},
"browser": {
"name": "Chrome"
},
"chrome": {
"name": "Chrome",
"type": "runtime",
"version": "{{version}}"
},
"device": {
"arch": "{{arch}}",
"family": "Desktop",
"memory_size": 0,
"free_memory": 0,
"processor_count": 0,
"processor_frequency": 0,
"cpu_description": "{{cpu}}",
"screen_resolution":"{{screen}}",
"screen_density": 1
},
"culture": {
"locale": "{{locale}}",
"timezone": "{{timezone}}"
},
"node": {
"name": "Node",
"type": "runtime",
"version": "{{version}}"
},
"os": {
"name": "{{platform}}",
"version": "{{version}}"
},
"runtime": {
"name": "Electron",
"version": "{{version}}"
},
"electron": {
"crashed_url": "app:///src/index.html"
}
},
"release": "session-native-crash-renderer-multiple@1.0.0",
"environment": "development",
"event_id": "{{id}}",
"timestamp": 0,
"breadcrumbs": [],
"tags": {
"event.environment": "native",
"event.origin": "electron",
"event.process": "renderer"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "session-native-crash-renderer-multiple",
"version": "1.0.0",
"main": "src/main.js",
"dependencies": {
"@sentry/electron": "3.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: Session with Multiple Native Renderer Crashes
category: Sessions
command: yarn
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"appId": "277345",
"sentryKey": "37f8a2ee37c0409d8970bc7559c7c7e4",
"method": "envelope",
"data": {
"sid": "{{id}}",
"init": false,
"started": 0,
"timestamp": 0,
"status": "crashed",
"errors": 1,
"duration": 0,
"attrs": {
"release": "session-native-crash-renderer-multiple@1.0.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"appId": "277345",
"sentryKey": "37f8a2ee37c0409d8970bc7559c7c7e4",
"method": "envelope",
"data": {
"sid": "{{id}}",
"init": false,
"started": 0,
"timestamp": 0,
"status": "ok",
"errors": 0,
"duration": 0,
"attrs": {
"release": "session-native-crash-renderer-multiple@1.0.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"appId": "277345",
"sentryKey": "37f8a2ee37c0409d8970bc7559c7c7e4",
"method": "envelope",
"data": {
"sid": "{{id}}",
"init": true,
"started": 0,
"timestamp": 0,
"status": "ok",
"errors": 0,
"duration": 0,
"attrs": {
"release": "session-native-crash-renderer-multiple@1.0.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<script>
const { init } = require('@sentry/electron/renderer');

init({
debug: true,
});

setTimeout(() => {
process.crash();
}, 500);
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const path = require('path');

const { app, BrowserWindow } = require('electron');
const { init, mainProcessSessionIntegration } = require('@sentry/electron/main');

init({
dsn: '__DSN__',
debug: true,
integrations: [mainProcessSessionIntegration({ sendOnCreate: true })],
onFatalError: () => {},
});

function createWindow() {
const mainWindow = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});

mainWindow.loadFile(path.join(__dirname, 'index.html'));
}

app.on('ready', () => {
createWindow();
});

setTimeout(() => {
createWindow();
}, 3000);

setTimeout(() => {
app.quit();
}, 10000);
2 changes: 1 addition & 1 deletion test/e2e/vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export default defineConfig({
retry: process.env.CI ? 3 : 0,
disableConsoleIntercept: true,
silent: false,
reporters: process.env.CI || process.env.DEBUG ? ['verbose', 'github-actions'] : ['verbose'],
reporters: process.env.DEBUG ? ['basic'] : process.env.CI ? ['verbose', 'github-actions'] : ['verbose'],
},
});
Loading