Skip to content

Commit

Permalink
Also check pending directory for crashpad
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish committed Nov 18, 2022
1 parent e07f06b commit 0deb19b
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/main/integrations/sentry-minidump/minidump-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function crashpadMinidumpLoader(): MinidumpLoader {
await deleteCrashpadMetadataFile(crashesDirectory).catch((error) => logger.error(error));

const dumpDirectory = join(crashesDirectory, crashpadSubDirectory);
const pendingDirectory = join(crashesDirectory, 'pending');

return (await readDirAsync(dumpDirectory))
.filter((file) => file.endsWith('.dmp'))
Expand All @@ -104,7 +105,19 @@ function crashpadMinidumpLoader(): MinidumpLoader {
path,
load: () => readFileAsync(path),
};
});
})
.concat(
(await readDirAsync(pendingDirectory))
.filter((file) => file.endsWith('.dmp'))
.map((file) => {
const path = join(pendingDirectory, file);

return {
path,
load: () => readFileAsync(path),
};
}),
);
});
}

Expand Down
83 changes: 83 additions & 0 deletions test/e2e/test-apps/native-sentry/renderer-force-crash/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-renderer-force-crash",
"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,
"language": "{{language}}"
},
"node": {
"name": "Node",
"type": "runtime",
"version": "{{version}}"
},
"os": {
"name": "{{platform}}",
"version": "{{version}}"
},
"runtime": {
"name": "Electron",
"version": "{{version}}"
},
"electron": {
"crashed_url": "unknown",
"details": {
"reason": "killed"
}
}
},
"release": "native-sentry-renderer-force-crash@1.0.0",
"environment": "development",
"user": {
"ip_address": "{{auto}}"
},
"event_id": "{{id}}",
"timestamp": 0,
"breadcrumbs": [],
"tags": {
"event.environment": "native",
"event.origin": "electron",
"event.process": "renderer",
"event_type": "native",
"exit.reason": "killed"
}
},
"attachments": [
{
"attachment_type": "event.minidump"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "native-sentry-renderer-force-crash",
"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: Native Renderer forcefullyCrashRenderer
category: Native (Sentry Uploader)
command: yarn
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');

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

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

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'));

setTimeout(() => {
mainWindow.webContents.forcefullyCrashRenderer();
}, 1000);
});

0 comments on commit 0deb19b

Please sign in to comment.