Skip to content

Commit

Permalink
test: More child process types (#1063)
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish authored Jan 21, 2025
1 parent 2cafb93 commit b849c20
Show file tree
Hide file tree
Showing 17 changed files with 424 additions and 0 deletions.
75 changes: 75 additions & 0 deletions test/e2e/test-apps/native-sentry/child-exec/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"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": "native-sentry-child-exec",
"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}}"
}
},
"release": "[email protected]",
"environment": "development",
"event_id": "{{id}}",
"timestamp": 0,
"breadcrumbs": [],
"tags": {
"event.environment": "native",
"event.origin": "electron",
"event.process": "unknown"
}
},
"attachments": [
{
"attachment_type": "event.minidump"
}
]
}
9 changes: 9 additions & 0 deletions test/e2e/test-apps/native-sentry/child-exec/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "native-sentry-child-exec",
"version": "1.0.0",
"main": "src/main.js",
"dependencies": {
"@sentry/electron": "5.6.0",
"crashy-cli": "1.0.1"
}
}
5 changes: 5 additions & 0 deletions test/e2e/test-apps/native-sentry/child-exec/recipe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Native Child Exec Crash
category: Native (Sentry Uploader)
command: yarn
runTwice: true
condition: platform === 'darwin'
15 changes: 15 additions & 0 deletions test/e2e/test-apps/native-sentry/child-exec/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<script>
const { init } = require('@sentry/electron/renderer');

init({
debug: true,
});
</script>
</body>
</html>
37 changes: 37 additions & 0 deletions test/e2e/test-apps/native-sentry/child-exec/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const path = require('path');
const child_process = require('child_process');

const { getPath } = require('crashy-cli');
const { app, BrowserWindow } = require('electron');
const { init } = require('@sentry/electron/main');

init({
dsn: '__DSN__',
debug: true,
autoSessionTracking: false,
onFatalError: () => {},
});

app.on('ready', () => {
const mainWindow = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});

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

if (process.env.APP_FIRST_RUN) {
try {
child_process.execSync(getPath());
} catch (_) {
//
}

setTimeout(() => {
app.exit();
}, 3000);
}
});
75 changes: 75 additions & 0 deletions test/e2e/test-apps/native-sentry/child-fork/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"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": "native-sentry-child-fork",
"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}}"
}
},
"release": "[email protected]",
"environment": "development",
"event_id": "{{id}}",
"timestamp": 0,
"breadcrumbs": [],
"tags": {
"event.environment": "native",
"event.origin": "electron",
"event.process": "node"
}
},
"attachments": [
{
"attachment_type": "event.minidump"
}
]
}
9 changes: 9 additions & 0 deletions test/e2e/test-apps/native-sentry/child-fork/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "native-sentry-child-fork",
"version": "1.0.0",
"main": "src/main.js",
"dependencies": {
"@sentry/electron": "5.6.0",
"sadness-generator": "0.0.2"
}
}
5 changes: 5 additions & 0 deletions test/e2e/test-apps/native-sentry/child-fork/recipe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Native Child Crash
category: Native (Sentry Uploader)
command: yarn
runTwice: true
condition: platform !== 'linux'
5 changes: 5 additions & 0 deletions test/e2e/test-apps/native-sentry/child-fork/src/child.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { raiseSegfault } = require('sadness-generator')

setTimeout(() => {
raiseSegfault();
}, 1000);
15 changes: 15 additions & 0 deletions test/e2e/test-apps/native-sentry/child-fork/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<script>
const { init } = require('@sentry/electron/renderer');

init({
debug: true,
});
</script>
</body>
</html>
32 changes: 32 additions & 0 deletions test/e2e/test-apps/native-sentry/child-fork/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const path = require('path');
const child_process = require('child_process');

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

init({
dsn: '__DSN__',
debug: true,
autoSessionTracking: false,
onFatalError: () => {},
});

app.on('ready', () => {
const mainWindow = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});

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

if (process.env.APP_FIRST_RUN) {
child_process.fork(path.join(__dirname, 'child.js'));

setTimeout(() => {
app.exit();
}, 3000);
}
});
83 changes: 83 additions & 0 deletions test/e2e/test-apps/native-sentry/utility/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"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": "native-sentry-utility",
"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": {
"details": {
"name": "Node Utility Process",
"reason": "crashed",
"type": "Utility"
}
}
},
"release": "[email protected]",
"environment": "development",
"event_id": "{{id}}",
"timestamp": 0,
"breadcrumbs": [],
"tags": {
"event.environment": "native",
"event.origin": "electron",
"event.process": "utility",
"exit.reason": "crashed"
}
},
"attachments": [
{
"attachment_type": "event.minidump"
}
]
}
9 changes: 9 additions & 0 deletions test/e2e/test-apps/native-sentry/utility/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "native-sentry-utility",
"version": "1.0.0",
"main": "src/main.js",
"dependencies": {
"@sentry/electron": "5.6.0",
"sadness-generator": "0.0.2"
}
}
5 changes: 5 additions & 0 deletions test/e2e/test-apps/native-sentry/utility/recipe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Native Utility Crash
category: Native (Sentry Uploader)
command: yarn
# Not working on Linux with v29.4.6
condition: version.major >= 22 && !(platform === 'linux' && version.major === 29)
5 changes: 5 additions & 0 deletions test/e2e/test-apps/native-sentry/utility/src/child.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { raiseSegfault } = require('sadness-generator')

setTimeout(() => {
raiseSegfault();
}, 1000);
Loading

0 comments on commit b849c20

Please sign in to comment.