Skip to content

Commit

Permalink
fix: Duplicate crashed sessions (#961)
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish authored Aug 26, 2024
1 parent cc60c02 commit 0cd436b
Show file tree
Hide file tree
Showing 11 changed files with 264 additions and 3 deletions.
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": "[email protected]",
"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": "[email protected]",
"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": "[email protected]"
}
}
}
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": "[email protected]"
}
}
}
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": "[email protected]"
}
}
}
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'],
},
});

0 comments on commit 0cd436b

Please sign in to comment.